X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=threads.h;h=a97a04c704449963981fe443a711c64abc716fb3;hp=7a21a30d8d93f49e4e0c13d37dfeb18f21260b47;hb=e8bc4a0715ce1c86f3ff7d24179e1164bf3ee61b;hpb=3cade2fadc95d3dcbc37f5e6c4da4b8e9b559c23 diff --git a/threads.h b/threads.h index 7a21a30d..a97a04c7 100644 --- a/threads.h +++ b/threads.h @@ -1,10 +1,16 @@ +/** @file threads.h + * @brief Model Checker Thread class. + */ + #ifndef __THREADS_H__ #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 { @@ -14,11 +20,12 @@ typedef enum thread_state { THREAD_COMPLETED } thread_state; +class ModelAction; + +/** @brief A Thread is created for each user-space thread */ class Thread { public: - void * operator new(size_t size); - void operator delete(void *ptr); - Thread(thrd_t *t, void (*func)(), void *a); + Thread(thrd_t *t, void (*func)(void *), void *a); ~Thread(); void complete(); @@ -29,10 +36,20 @@ 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; } + + void set_creation(ModelAction *act) { creation = act; } + ModelAction * get_creation() { return creation; } + + friend void thread_startup(); + + SNAPSHOTALLOC private: int create_context(); + Thread *parent; + ModelAction *creation; - void (*start_routine)(); + void (*start_routine)(void *); void *arg; ucontext_t context; void *stack;