Make userspace actually work.
[pintos-anon] / src / threads / thread.h
1 #ifndef HEADER_THREAD_H
2 #define HEADER_THREAD_H 1
3
4 #include <stdint.h>
5 #include "debug.h"
6 #include "list.h"
7
8 #ifdef USERPROG
9 #include "addrspace.h"
10 #endif
11
12 enum thread_status 
13   {
14     THREAD_RUNNING,
15     THREAD_READY,
16     THREAD_BLOCKED,
17     THREAD_DYING
18   };
19
20 struct thread 
21   {
22     enum thread_status status;
23     char name[16];
24     uint8_t *stack;
25     list_elem rq_elem;
26 #ifdef USERPROG
27     struct addrspace addrspace;
28 #endif
29   };
30
31 void thread_init (void);
32
33 struct thread *thread_create (const char *name,
34                               void (*function) (void *aux), void *aux);
35 void thread_destroy (struct thread *);
36 struct thread *thread_current (void);
37
38 #ifdef USERPROG
39 bool thread_execute (const char *filename);
40 #endif
41
42 void thread_start (struct thread *);
43 void thread_ready (struct thread *);
44 void thread_exit (void) NO_RETURN;
45
46 void thread_yield (void);
47 void thread_sleep (void);
48 void thread_schedule (void);
49
50 void thread_self_test (void);
51
52 #endif /* thread.h */