X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.h;h=b592804db95959445d5c4f967f449121e2d59bad;hb=018d30be3784726642f6fbff03c669b59798eea7;hp=69bd115c4a88243657ce8f92088962f97249dccb;hpb=a6f86729fc2e64ae7286d74094cb2f9d7745c17a;p=model-checker.git diff --git a/threads.h b/threads.h index 69bd115..b592804 100644 --- a/threads.h +++ b/threads.h @@ -2,9 +2,11 @@ #define __THREADS_H__ #include - +#include "mymemory.h" #include "libthreads.h" +typedef int thread_id_t; + #define THREAD_ID_T_NONE -1 typedef enum thread_state { @@ -16,8 +18,6 @@ typedef enum thread_state { class Thread { public: - void * operator new(size_t size); - void operator delete(void *ptr); Thread(thrd_t *t, void (*func)(), void *a); ~Thread(); void complete(); @@ -29,8 +29,11 @@ public: void set_state(thread_state s) { state = s; } thread_id_t get_id(); thrd_t get_thrd_t() { return *user_thread; } + Thread * get_parent() { return parent; } + MEMALLOC private: int create_context(); + Thread *parent; void (*start_routine)(); void *arg; @@ -48,4 +51,14 @@ static inline thread_id_t thrd_to_id(thrd_t t) return t; } +static inline thread_id_t int_to_id(int i) +{ + return i; +} + +static inline int id_to_int(thread_id_t id) +{ + return id; +} + #endif /* __THREADS_H__ */