Explain why a null pointer sentinel must be pushed on the stack.
[pintos-anon] / solutions / p3.patch
index 0ac49841dc1081b04fa98a2af3ffb977b456282d..3e7fb8ba63b619728ac53c63fc6f01574892078e 100644 (file)
@@ -289,9 +289,9 @@ diff -u src/threads/thread.h~ src/threads/thread.h
 +    struct semaphore dead;              /* 1=child alive, 0=child dead. */
 +  };
 +
- void thread_init (void);
- void thread_start (void);
+ /* If false (default), use round-robin scheduler.
+    If true, use multi-level feedback queue scheduler.
+    Controlled by kernel command-line options "-o mlfqs".
 Index: src/userprog/exception.c
 diff -u src/userprog/exception.c~ src/userprog/exception.c
 --- src/userprog/exception.c~
@@ -358,12 +358,12 @@ diff -u src/userprog/process.c~ src/userprog/process.c
 +#include "vm/page.h"
 +#include "vm/frame.h"
  
- static thread_func execute_thread NO_RETURN;
+ static thread_func start_process NO_RETURN;
 -static bool load (const char *cmdline, void (**eip) (void), void **esp);
 +static bool load (const char *cmd_line, void (**eip) (void), void **esp);
 +
 +/* Data structure shared between process_execute() in the
-+   invoking thread and execute_thread() in the newly invoked
++   invoking thread and start_process() in the newly invoked
 +   thread. */
 +struct exec_info 
 +  {
@@ -396,12 +396,12 @@ diff -u src/userprog/process.c~ src/userprog/process.c
 +  sema_init (&exec.load_done, 0);
  
    /* Create a new thread to execute FILE_NAME. */
--  tid = thread_create (file_name, PRI_DEFAULT, execute_thread, fn_copy);
+-  tid = thread_create (file_name, PRI_DEFAULT, start_process, fn_copy);
 -  if (tid == TID_ERROR)
 -    palloc_free_page (fn_copy); 
 +  strlcpy (thread_name, file_name, sizeof thread_name);
 +  strtok_r (thread_name, " ", &save_ptr);
-+  tid = thread_create (thread_name, PRI_DEFAULT, execute_thread, &exec);
++  tid = thread_create (thread_name, PRI_DEFAULT, start_process, &exec);
 +  if (tid != TID_ERROR)
 +    {
 +      sema_down (&exec.load_done);
@@ -417,15 +417,15 @@ diff -u src/userprog/process.c~ src/userprog/process.c
  /* A thread function that loads a user process and starts it
     running. */
  static void
--execute_thread (void *file_name_)
-+execute_thread (void *exec_)
+-start_process (void *file_name_)
++start_process (void *exec_)
  {
 -  char *file_name = file_name_;
 +  struct exec_info *exec = exec_;
    struct intr_frame if_;
    bool success;
  
-@@ -59,10 +81,28 @@ execute_thread (void *file_name_)
+@@ -59,10 +81,28 @@ start_process (void *file_name_)
    if_.gs = if_.fs = if_.es = if_.ds = if_.ss = SEL_UDSEG;
    if_.cs = SEL_UCSEG;
    if_.eflags = FLAG_IF | FLAG_MBS;
@@ -457,7 +457,7 @@ diff -u src/userprog/process.c~ src/userprog/process.c
    if (!success) 
      thread_exit ();
  
-@@ -76,18 +116,47 @@ execute_thread (void *file_name_)
+@@ -76,18 +116,47 @@ start_process (void *file_name_)
    NOT_REACHED ();
  }
  
@@ -817,7 +817,7 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
  #include <syscall-nr.h>
 +#include "userprog/process.h"
 +#include "userprog/pagedir.h"
-+#include "devices/kbd.h"
++#include "devices/input.h"
 +#include "filesys/directory.h"
 +#include "filesys/filesys.h"
 +#include "filesys/file.h"
@@ -1159,7 +1159,7 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 +          
 +          for (i = 0; i < read_amt; i++) 
 +            {
-+              char c = kbd_getc ();
++              char c = input_getc ();
 +              if (!page_lock (udst, true)) 
 +                thread_exit ();
 +              udst[i] = c;