Implement helper functions for managing the supplemental page table #55

Merged
td1223 merged 4 commits from page-swap-helpers into virtual-memory 2024-12-01 21:47:31 +00:00
4 changed files with 26 additions and 2 deletions
Showing only changes of commit 9d35beb2e4 - Show all commits

View File

@@ -1,6 +1,6 @@
# -*- makefile -*-
kernel.bin: DEFINES = -DUSERPROG -DFILESYS -DVM
kernel.bin: DEFINES = -DUSERPROG -DFILESYS
KERNEL_SUBDIRS = threads devices lib lib/kernel userprog filesys vm
TEST_SUBDIRS = tests/userprog tests/userprog/no-vm tests/filesys/base
GRADING_FILE = $(SRCDIR)/tests/userprog/Grading

View File

@@ -118,14 +118,20 @@ frame_alloc (enum palloc_flags flags, void *upage, struct thread *owner)
frame_metadata->frame = frame;
/* Newly allocated frames are pushed to the back of the circular queue
represented by lru_list. */
struct list_elem *lru_tail = lru_prev (next_victim);
list_insert (lru_tail, &frame_metadata->list_elem);
represented by lru_list. Must explicitly handle the case where the
circular queue is empty (when next_victim == NULL). */
if (next_victim == NULL)
{
list_push_back (&lru_list, &frame_metadata->list_elem);
next_victim = &frame_metadata->list_elem;
}
else
{
struct list_elem *lru_tail = lru_prev (next_victim);
list_insert (lru_tail, &frame_metadata->list_elem);
}
hash_insert (&frame_table, &frame_metadata->hash_elem);
if (next_victim == NULL)
next_victim = &frame_metadata->list_elem;
}
frame_metadata->upage = upage;