Move user exception support into userprog.
[pintos-anon] / src / threads / thread.c
index fed6b841aded48864edee8307fec6fb6090c87ae..d89edd6c8dcad5dcbe9cae5f21c2273c19be1f4d 100644 (file)
@@ -4,11 +4,13 @@
 #include "interrupt.h"
 #include "intr-stubs.h"
 #include "lib.h"
-#include "gdt.h"
 #include "mmu.h"
 #include "palloc.h"
 #include "random.h"
 #include "switch.h"
+#ifdef USERPROG
+#include "gdt.h"
+#endif
 
 #define THREAD_MAGIC 0x1234abcdu
 
@@ -24,11 +26,11 @@ static void idle (void *aux UNUSED);    /* Thread function. */
 struct kernel_thread_frame 
   {
     void *eip;                  /* Return address. */
-    void (*function) (void *);  /* Function to call. */
+    thread_func *function;      /* Function to call. */
     void *aux;                  /* Auxiliary data for function. */
   };
 
-static void kernel_thread (void (*function) (void *aux), void *aux);
+static void kernel_thread (thread_func *, void *aux);
 
 static struct thread *next_thread_to_run (void);
 static struct thread *new_thread (const char *name);
@@ -76,7 +78,7 @@ thread_start (void)
    semaphore or some other form of synchronization if you need to
    ensure ordering. */
 struct thread *
-thread_create (const char *name, void (*function) (void *aux), void *aux) 
+thread_create (const char *name, thread_func *function, void *aux) 
 {
   struct thread *t;
   struct kernel_thread_frame *kf;
@@ -263,7 +265,7 @@ idle (void *aux UNUSED)
 
 /* Function used as the basis for a kernel thread. */
 static void
-kernel_thread (void (*function) (void *aux), void *aux) 
+kernel_thread (thread_func *function, void *aux) 
 {
   ASSERT (function != NULL);
 
@@ -337,7 +339,9 @@ destroy_thread (struct thread *t)
   ASSERT (t->status == THREAD_DYING);
   ASSERT (t != thread_current ());
 
+#ifdef USERPROG
   addrspace_destroy (t);
+#endif
   palloc_free (t);
 }