Clean up threads.
[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_INITIALIZING,
15     THREAD_RUNNING,
16     THREAD_READY,
17     THREAD_BLOCKED,
18     THREAD_DYING
19   };
20
21 struct thread 
22   {
23     enum thread_status status;
24     char name[16];
25     uint8_t *stack;
26     list_elem rq_elem;
27 #ifdef USERPROG
28     struct addrspace addrspace;
29 #endif
30   };
31
32 void thread_init (void);
33 void thread_start (void) NO_RETURN;
34
35 struct thread *thread_create (const char *name, void (*) (void *aux), void *);
36 #ifdef USERPROG
37 bool thread_execute (const char *filename);
38 #endif
39
40 void thread_destroy (struct thread *);
41 void thread_ready (struct thread *);
42
43 struct thread *thread_current (void);
44 void thread_exit (void) NO_RETURN;
45 void thread_yield (void);
46 void thread_sleep (void);
47
48 #endif /* thread.h */