fix: obtain correct page table entry when performing eviction

This commit is contained in:
Themis Demetriades
2024-12-06 00:56:03 +00:00
parent 8220b931a9
commit 31403ac7cb
5 changed files with 8 additions and 7 deletions

View File

@@ -47,7 +47,7 @@ struct page_entry *
page_insert_swapped (void *upage, void *kpage, struct thread *owner)
{
/* 1. Initialize swapped page entry. */
struct page_entry *page = page_get (upage);
struct page_entry *page = page_get (thread_current (), upage);
if (page == NULL)
{
page = malloc (sizeof (struct page_entry));
@@ -103,13 +103,13 @@ page_insert_file (struct file *file, off_t ofs, void *upage,
/* Gets a page_entry from the starting address of the page. Returns NULL if no
such page_entry exists in the hash map.*/
struct page_entry *
page_get (void *upage)
page_get (struct thread *thread, void *upage)
{
struct page_entry fake_page_entry;
fake_page_entry.upage = upage;
struct hash_elem *e
= hash_find (&thread_current ()->pages, &fake_page_entry.elem);
= hash_find (&thread->pages, &fake_page_entry.elem);
if (e == NULL)
return NULL;