Add another test that checks priority scheduling in the case of
[pintos-anon] / solutions / p2.patch
index e1d72745b617dd3186bcfa4772d9f08bb67271f3..83d91fe22d7c2776869a1e268b21fdc1d454b988 100644 (file)
@@ -122,10 +122,10 @@ diff -u src/userprog/process.c~ src/userprog/process.c
 @@ -14,11 +14,23 @@
  #include "threads/init.h"
  #include "threads/interrupt.h"
- #include "threads/mmu.h"
 +#include "threads/malloc.h"
  #include "threads/palloc.h"
  #include "threads/thread.h"
+ #include "threads/vaddr.h"
  
  static thread_func execute_thread NO_RETURN;
 -static bool load (const char *cmdline, void (**eip) (void), void **esp);
@@ -313,14 +313,14 @@ diff -u src/userprog/process.c~ src/userprog/process.c
       to the kernel-only page directory. */
    pd = cur->pagedir;
 @@ -193,7 +284,7 @@ struct Elf32_Phdr
+ #define PF_W 2          /* Writable. */
  #define PF_R 4          /* Readable. */
  
- static bool load_segment (struct file *, const struct Elf32_Phdr *);
 -static bool setup_stack (void **esp);
 +static bool setup_stack (const char *cmd_line, void **esp);
- /* Loads an ELF executable from FILENAME into the current thread.
-    Stores the executable's entry point into *EIP
+ static bool validate_segment (const struct Elf32_Phdr *, struct file *);
+ static bool load_segment (struct file *file, off_t ofs, uint8_t *upage,
+                           bool writable);
 @@ -209,13 +300,15 @@ static bool setup_stack (void **esp);
     and its initial stack pointer into *ESP.
     Returns true if successful, false otherwise. */
@@ -479,11 +479,11 @@ diff -u src/userprog/process.c~ src/userprog/process.c
    kpage = palloc_get_page (PAL_USER | PAL_ZERO);
    if (kpage != NULL) 
      {
--      success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage);
+-      success = install_page (((uint8_t *) PHYS_BASE) - PGSIZE, kpage, true);
 -      if (success)
 -        *esp = PHYS_BASE;
 +      uint8_t *upage = ((uint8_t *) PHYS_BASE) - PGSIZE;
-+      if (install_page (upage, kpage))
++      if (install_page (upage, kpage, true))
 +        success = init_cmd_line (kpage, upage, cmd_line, esp);
        else
          palloc_free_page (kpage);
@@ -491,7 +491,7 @@ diff -u src/userprog/process.c~ src/userprog/process.c
 diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 --- src/userprog/syscall.c~ 2004-09-26 14:15:17.000000000 -0700
 +++ src/userprog/syscall.c 2005-06-08 13:45:28.000000000 -0700
-@@ -1,20 +1,480 @@
+@@ -1,20 +1,482 @@
  #include "userprog/syscall.h"
  #include <stdio.h>
 +#include <string.h>
@@ -504,9 +504,9 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 +#include "threads/init.h"
  #include "threads/interrupt.h"
 +#include "threads/malloc.h"
-+#include "threads/mmu.h"
 +#include "threads/palloc.h"
  #include "threads/thread.h"
++#include "threads/vaddr.h"
 -
 + 
 + 
@@ -972,7 +972,9 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 +      struct file_descriptor *fd;
 +      fd = list_entry (e, struct file_descriptor, elem);
 +      next = list_next (e);
++      lock_acquire (&fs_lock);
 +      file_close (fd->file);
++      lock_release (&fs_lock);
 +      free (fd);
 +    }
 +}