Refactor page to follow pintos styling for indentation and add spacing for readability

This commit is contained in:
sBubshait
2024-12-06 18:36:54 +00:00
parent 5fbabdcec9
commit 8d1b4c4994

View File

@@ -195,6 +195,7 @@ page_load_file (struct page_entry *page)
lock_acquire (&shared_file_pages_lock); lock_acquire (&shared_file_pages_lock);
struct shared_file_page *sfp struct shared_file_page *sfp
= shared_file_page_get (page->file, page->upage); = shared_file_page_get (page->file, page->upage);
if (sfp != NULL) if (sfp != NULL)
{ {
/* Frame exists, just install it. */ /* Frame exists, just install it. */
@@ -207,7 +208,8 @@ page_load_file (struct page_entry *page)
} }
frame_owner_insert (sfp->frame, t); frame_owner_insert (sfp->frame, t);
} }
/* Shared page is in swap. Load it. */
/* Otherwise, shared page is in swap. Load it. */
else else
{ {
void *frame = frame_alloc (PAL_USER, page->upage, t); void *frame = frame_alloc (PAL_USER, page->upage, t);
@@ -223,6 +225,7 @@ page_load_file (struct page_entry *page)
return false; return false;
} }
} }
page_flag_shared (t, page->upage, true); page_flag_shared (t, page->upage, true);
if (page->type != PAGE_SHARED) if (page->type != PAGE_SHARED)
{ {
@@ -320,12 +323,12 @@ page_cleanup (struct hash_elem *e, void *aux UNUSED)
/* Flags the provided page table entry as representing a swapped out page. */ /* Flags the provided page table entry as representing a swapped out page. */
void void
page_flag_swap (uint32_t *pte, bool set) page_flag_swap (uint32_t *pte, bool set)
{ {
if (set) if (set)
*pte |= (1 << SWAP_FLAG_BIT); *pte |= (1 << SWAP_FLAG_BIT);
else else
*pte &= ~(1 << SWAP_FLAG_BIT); *pte &= ~(1 << SWAP_FLAG_BIT);
} }
/* Sets the address bits of the page table entry to the provided swap slot /* Sets the address bits of the page table entry to the provided swap slot
value. To be used for later retrieval of the swap slot when page faulting. */ value. To be used for later retrieval of the swap slot when page faulting. */