Clean up threads.
[pintos-anon] / src / threads / thread.h
index b72c372b7ac98407e353480af5a7e1808dd32c23..5cfbadfbfb303bc2fbb69ecf6a72e85732803dbc 100644 (file)
@@ -2,8 +2,13 @@
 #define HEADER_THREAD_H 1
 
 #include <stdint.h>
+#include "debug.h"
 #include "list.h"
 
+#ifdef USERPROG
+#include "addrspace.h"
+#endif
+
 enum thread_status 
   {
     THREAD_RUNNING,
@@ -14,25 +19,30 @@ enum thread_status
 
 struct thread 
   {
-    enum thread_status status;
-    char name[16];
-    uint32_t *stack;
-    struct list_elem rq_elem;
+    enum thread_status status;          /* Thread state. */
+    char name[16];                      /* Name (for debugging purposes). */
+    uint8_t *stack;                     /* Saved stack pointer. */
+    list_elem rq_elem;                  /* Run queue list element. */
+#ifdef USERPROG
+    struct addrspace addrspace;         /* Userland address space. */
+#endif
+    unsigned magic;                     /* Always set to THREAD_MAGIC. */
   };
 
 void thread_init (void);
+void thread_start (void) NO_RETURN;
 
-struct thread *thread_create (const char *name,
-                              void (*function) (void *aux), void *aux);
-void thread_destroy (struct thread *);
-struct thread *thread_current (void);
+struct thread *thread_create (const char *name, void (*) (void *aux), void *);
+#ifdef USERPROG
+bool thread_execute (const char *filename);
+#endif
 
-void thread_start (struct thread *);
-void thread_ready (struct thread *);
-void thread_exit (void);
+void thread_wake (struct thread *);
+const char *thread_name (struct thread *);
 
+struct thread *thread_current (void);
+void thread_exit (void) NO_RETURN;
 void thread_yield (void);
 void thread_sleep (void);
-void thread_schedule (void);
 
 #endif /* thread.h */