libthreads: make typedef for 'thread_id_t'
[model-checker.git] / libthreads.h
1 #ifndef __LIBTHREADS_H__
2 #define __LIBTHREADS_H__
3
4 #include <ucontext.h>
5
6 typedef enum thread_state {
7         THREAD_CREATED,
8         THREAD_RUNNING,
9         THREAD_READY,
10         THREAD_COMPLETED
11 } thread_state;
12
13 typedef int thread_id_t;
14
15 struct thread {
16         void (*start_routine)();
17         void *arg;
18         ucontext_t context;
19         void *stack;
20         thread_id_t id;
21         thread_state state;
22 };
23
24 int thread_create(struct thread *t, void (*start_routine)(), void *arg);
25 void thread_join(struct thread *t);
26 int thread_yield(void);
27 struct thread *thread_current(void);
28
29 extern void user_main(void);
30
31 #endif /* __LIBTHREADS_H__ */