Refactor mmap system call code to follow pintos style in indentation
This commit is contained in:
@@ -67,26 +67,27 @@ mmap_unmap (struct mmap_entry *mmap)
|
|||||||
if necessary. */
|
if necessary. */
|
||||||
off_t length = file_length (mmap->file);
|
off_t length = file_length (mmap->file);
|
||||||
for (off_t ofs = 0; ofs < length; ofs += PGSIZE)
|
for (off_t ofs = 0; ofs < length; ofs += PGSIZE)
|
||||||
{
|
|
||||||
void *upage = mmap->upage + ofs;
|
|
||||||
|
|
||||||
/* Get the SPT page entry for this page. */
|
|
||||||
struct page_entry *page = page_get(thread_current (), upage);
|
|
||||||
if (page == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Write the page back to the file if it is dirty. */
|
|
||||||
if (pagedir_is_dirty (thread_current ()->pagedir, upage))
|
|
||||||
{
|
{
|
||||||
lock_acquire (&filesys_lock);
|
void *upage = mmap->upage + ofs;
|
||||||
file_write_at (mmap->file, upage, page->read_bytes, ofs);
|
|
||||||
lock_release (&filesys_lock);
|
/* Get the SPT page entry for this page. */
|
||||||
|
struct page_entry *page = page_get(thread_current (), upage);
|
||||||
|
if (page == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Write the page back to the file if it is dirty. */
|
||||||
|
if (pagedir_is_dirty (thread_current ()->pagedir, upage))
|
||||||
|
{
|
||||||
|
lock_acquire (&filesys_lock);
|
||||||
|
file_write_at (mmap->file, upage, page->read_bytes, ofs);
|
||||||
|
lock_release (&filesys_lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove the page from the supplemental page table. */
|
||||||
|
hash_delete (&thread_current ()->pages, &page->elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove the page from the supplemental page table. */
|
/* Close the file and free the mmap entry. */
|
||||||
hash_delete (&thread_current ()->pages, &page->elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
file_close (mmap->file);
|
file_close (mmap->file);
|
||||||
free (mmap);
|
free (mmap);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user