refactor: add comments describing each type of page fault dealt by the page fault handler
This commit is contained in:
@@ -155,11 +155,15 @@ page_fault (struct intr_frame *f)
|
|||||||
user = (f->error_code & PF_U) != 0;
|
user = (f->error_code & PF_U) != 0;
|
||||||
|
|
||||||
#ifdef VM
|
#ifdef VM
|
||||||
|
struct thread *t = thread_current ();
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
if (not_present)
|
if (not_present)
|
||||||
{
|
{
|
||||||
struct thread *t = thread_current ();
|
/* Check if the non-present user page is in the swap partition.
|
||||||
|
If so, swap it back into main memory, updating the PTE for
|
||||||
|
the faulted virtual address to point to the newly allocated
|
||||||
|
frame. */
|
||||||
if (page_in_swap (t, fault_addr))
|
if (page_in_swap (t, fault_addr))
|
||||||
{
|
{
|
||||||
size_t swap_slot = page_get_swap (t, fault_addr);
|
size_t swap_slot = page_get_swap (t, fault_addr);
|
||||||
@@ -171,15 +175,18 @@ page_fault (struct intr_frame *f)
|
|||||||
if (pagedir_set_page (t->pagedir, upage, kpage, writeable)) return;
|
if (pagedir_set_page (t->pagedir, upage, kpage, writeable)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle page faults that need to be resolved by dynamic stack growth
|
/* Handle user page faults that need to be resolved by dynamic
|
||||||
by checking if this is such a fault and resolving it appropriately. */
|
stack growth by checking if this is such a fault and responding
|
||||||
|
accordingly. */
|
||||||
if (handle_stack_fault (fault_addr, f->esp)) return;
|
if (handle_stack_fault (fault_addr, f->esp)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Allows for stack growth in kernel context, due to syscall failure */
|
/* Handle kernel page faults that need to be resolved by dynamic stack
|
||||||
if (handle_stack_fault (fault_addr, thread_current ()->curr_esp)) return;
|
growth by checking if this is such a fault and responding
|
||||||
|
accordingly. */
|
||||||
|
if (not_present && handle_stack_fault (fault_addr, t->curr_esp)) return;
|
||||||
|
|
||||||
f->eip = (void *)f->eax;
|
f->eip = (void *)f->eax;
|
||||||
f->eax = 0xffffffff;
|
f->eax = 0xffffffff;
|
||||||
|
|||||||
Reference in New Issue
Block a user