Merge branch 'virtual-memory' into 'page-swap-helpers'
# Conflicts: # src/vm/frame.c # src/vm/page.c
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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. */
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user