solutions: Fix mangled p4.patch.
[pintos-anon] / solutions / p2.patch
index 00711a2a484aead2743ddcb81a6cd0bd7e86167d..41f6764d445a0c27b2218abffec0bc202f95cf01 100644 (file)
@@ -10,12 +10,10 @@ diff -u src/threads/thread.c~ src/threads/thread.c
  #endif
  
  /* Random value for struct thread's `magic' member.
-@@ -251,16 +252,19 @@ thread_tid (void) 
+@@ -251,18 +252,19 @@ thread_tid (void) 
  void
  thread_exit (void) 
  {
-+  struct thread *t = thread_current ();
-+
    ASSERT (!intr_context ());
  
  #ifdef USERPROG
@@ -24,11 +22,12 @@ diff -u src/threads/thread.c~ src/threads/thread.c
 -
 +  syscall_exit ();
 +  
-   /* Just set our status to dying and schedule another process.
-      We will be destroyed during the call to schedule_tail(). */
+   /* Remove thread from all threads list, set our status to dying,
+      and schedule another process.  That process will destroy us
+      when it calls thread_schedule_tail(). */
    intr_disable ();
--  thread_current ()->status = THREAD_DYING;
-+  t->status = THREAD_DYING;
+   list_remove (&thread_current()->allelem);
+   thread_current ()->status = THREAD_DYING;
    schedule ();
    NOT_REACHED ();
  }
@@ -501,9 +500,9 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 +#include "userprog/process.h"
 +#include "userprog/pagedir.h"
 +#include "devices/input.h"
++#include "devices/shutdown.h"
 +#include "filesys/filesys.h"
 +#include "filesys/file.h"
-+#include "threads/init.h"
  #include "threads/interrupt.h"
 +#include "threads/malloc.h"
 +#include "threads/palloc.h"
@@ -620,7 +619,7 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 +{
 +  int eax;
 +  asm ("movl $1f, %%eax; movb %b2, %0; 1:"
-+       : "=m" (*udst), "=&a" (eax) : "r" (byte));
++       : "=m" (*udst), "=&a" (eax) : "q" (byte));
 +  return eax != 0;
 +}
 + 
@@ -673,7 +672,7 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c
 +static int
 +sys_halt (void)
 +{
-+  power_off ();
++  shutdown_power_off ();
 +}
 + 
 +/* Exit system call. */