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