Merge branch 'vm/syscall-mmap/styling' into 'master'

Refactor mmap system call code to follow pintos style in indentation

See merge request lab2425_autumn/pintos_22!67
This commit is contained in:
Saleh Bubshait
2024-12-06 18:15:47 +00:00

View File

@@ -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);
} }