X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=solutions%2Fp4.patch;h=057d0a79165e3606a018459d6ffad0bdd19c6a80;hb=4d4f7cdae7c29fc7dfcecc16c6a683dd512532cf;hp=614c37924a153ef2b83b1cf55c001c10fe77625a;hpb=4ebf33908a571a7cde93fe618902b044e3633cdf;p=pintos-anon diff --git a/solutions/p4.patch b/solutions/p4.patch index 614c379..057d0a7 100644 --- a/solutions/p4.patch +++ b/solutions/p4.patch @@ -102,16 +102,18 @@ diff -u src/devices/timer.c~ src/devices/timer.c diff -u src/filesys/Make.vars~ src/filesys/Make.vars --- src/filesys/Make.vars~ 2005-05-24 14:46:45.000000000 -0700 +++ src/filesys/Make.vars 2005-06-16 15:09:31.000000000 -0700 -@@ -6,6 +6,6 @@ KERNEL_SUBDIRS = threads devices lib lib - TEST_SUBDIRS = tests/userprog tests/filesys/base tests/filesys/extended +@@ -6,7 +6,7 @@ KERNEL_SUBDIRS = threads devices lib lib + GRADING_FILE = $(SRCDIR)/tests/filesys/Grading.no-vm # Uncomment the lines below to enable VM. -#os.dsk: DEFINES += -DVM -#KERNEL_SUBDIRS += vm -#TEST_SUBDIRS += tests/vm +-#GRADING_FILE = $(SRCDIR)/tests/filesys/Grading.with-vm +os.dsk: DEFINES += -DVM +KERNEL_SUBDIRS += vm +TEST_SUBDIRS += tests/vm ++GRADING_FILE = $(SRCDIR)/tests/filesys/Grading.with-vm diff -u src/filesys/cache.c~ src/filesys/cache.c --- src/filesys/cache.c~ 1969-12-31 16:00:00.000000000 -0800 +++ src/filesys/cache.c 2005-06-16 15:09:31.000000000 -0700 @@ -1530,7 +1532,7 @@ diff -u src/filesys/inode.c~ src/filesys/inode.c /* Closes INODE and writes it to disk. If this was the last reference to INODE, frees its memory. If INODE was also a removed inode, frees its blocks. */ -@@ -158,18 +181,59 @@ inode_close (struct inode *inode) +@@ -158,21 +181,60 @@ inode_close (struct inode *inode) return; /* Release resources if this was the last opener. */ @@ -1540,13 +1542,16 @@ diff -u src/filesys/inode.c~ src/filesys/inode.c /* Remove from inode list and release lock. */ list_remove (&inode->elem); + lock_release (&open_inodes_lock); - + /* Deallocate blocks if removed. */ - if (inode->removed) -- free_map_release (inode->sector, -- bytes_to_sectors (inode->data.length)); -- + if (inode->removed) +- { +- free_map_release (inode->sector, 1); +- free_map_release (inode->data.start, +- bytes_to_sectors (inode->data.length)); +- } + deallocate_inode (inode); + free (inode); } + else @@ -2561,7 +2566,7 @@ diff -u src/userprog/process.c~ src/userprog/process.c ASSERT (file != NULL); ASSERT (phdr != NULL); -@@ -332,69 +458,129 @@ load_segment (struct file *file, const s +@@ -332,73 +458,129 @@ load_segment (struct file *file, const s || start == 0) return false; @@ -2681,7 +2686,7 @@ diff -u src/userprog/process.c~ src/userprog/process.c - *esp = PHYS_BASE; - else - palloc_free_page (kpage); -+ char *uarg = upage + (karg - (char *) kpage); ++ void *uarg = upage + (karg - (char *) kpage); + if (push (kpage, &ofs, &uarg, sizeof uarg) == NULL) + return false; + argc++; @@ -2704,8 +2709,12 @@ diff -u src/userprog/process.c~ src/userprog/process.c } -/* Adds a mapping from user virtual address UPAGE to kernel -- virtual address KPAGE to the page table. Fails if UPAGE is -- already mapped or if memory allocation fails. */ +- virtual address KPAGE to the page table. +- UPAGE must not already be mapped. +- KPAGE should probably be a page obtained from the user pool +- with palloc_get_page(). +- Returns true on success, false if UPAGE is already mapped or +- if memory allocation fails. */ +/* Create a minimal stack for T by mapping a page at the + top of user virtual memory. Fills in the page using CMD_LINE + and sets *ESP to the stack pointer. */ @@ -3542,7 +3551,7 @@ diff -u src/vm/frame.h~ src/vm/frame.h diff -u src/vm/page.c~ src/vm/page.c --- src/vm/page.c~ 1969-12-31 16:00:00.000000000 -0800 +++ src/vm/page.c 2005-06-16 15:09:31.000000000 -0700 -@@ -0,0 +1,297 @@ +@@ -0,0 +1,294 @@ +#include "vm/page.h" +#include +#include @@ -3557,29 +3566,26 @@ diff -u src/vm/page.c~ src/vm/page.c +/* Maximum size of process stack, in bytes. */ +#define STACK_MAX (1024 * 1024) + ++/* Destroys a page, which must be in the current process's ++ page table. Used as a callback for hash_destroy(). */ ++static void ++destroy_page (struct hash_elem *p_, void *aux UNUSED) ++{ ++ struct page *p = hash_entry (p_, struct page, hash_elem); ++ frame_lock (p); ++ if (p->frame) ++ frame_free (p->frame); ++ free (p); ++} ++ ++ +/* Destroys the current process's page table. */ +void +page_exit (void) +{ -+ struct hash *h; -+ struct hash_iterator i; -+ -+ h = thread_current ()->pages; -+ if (h == NULL) -+ return; -+ -+ hash_first (&i, h); -+ hash_next (&i); -+ while (hash_cur (&i)) -+ { -+ struct page *p = hash_entry (hash_cur (&i), struct page, hash_elem); -+ hash_next (&i); -+ frame_lock (p); -+ if (p->frame) -+ frame_free (p->frame); -+ free (p); -+ } -+ hash_destroy (h); ++ struct hash *h = thread_current ()->pages; ++ if (h != NULL) ++ hash_destroy (h, destroy_page); +} + +/* Returns the page containing the given virtual ADDRESS,