#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
-
+ 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 ();
}
+#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"
+{
+ 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;
+}
+
+static int
+sys_halt (void)
+{
-+ power_off ();
++ shutdown_power_off ();
+}
+
+/* Exit system call. */