X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=threads-model.h;h=fd0314ad6b9fa34ac5a42c0fd9cfd94f6f552753;hb=ebbaf2d1ff97315fdf97943f122392d1a449e41b;hp=9a4d959ddd8d380c2562d624b97fc8059f315444;hpb=84d0cd2f078f4cb15c318a0fef2515feab570375;p=c11tester.git diff --git a/threads-model.h b/threads-model.h index 9a4d959d..fd0314ad 100644 --- a/threads-model.h +++ b/threads-model.h @@ -13,6 +13,11 @@ #include #include "modeltypes.h" +struct thread_params { + thrd_start_t func; + void *arg; +}; + /** @brief Represents the state of a user Thread */ typedef enum thread_state { /** Thread was just created and hasn't run yet */ @@ -44,7 +49,7 @@ public: static int swap(Thread *t, ucontext_t *ctxt); thread_state get_state() const { return state; } - void set_state(thread_state s) { state = s; } + void set_state(thread_state s); thread_id_t get_id() const; thrd_t get_thrd_t() const { return *user_thread; } Thread * get_parent() const { return parent; } @@ -90,8 +95,15 @@ public: return wait_list[i]; } + /** @return The pending (next) ModelAction for this Thread + * @see Thread::pending */ ModelAction * get_pending() const { return pending; } + + /** @brief Set the pending (next) ModelAction for this Thread + * @param act The pending ModelAction + * @see Thread::pending */ void set_pending(ModelAction *act) { pending = act; } + /** * Remove one ModelAction from the waiting list * @return The ModelAction that was removed from the waiting list @@ -114,10 +126,22 @@ public: */ private: int create_context(); + + /** @brief The parent Thread which created this Thread */ Thread *parent; + + /** @brief The THREAD_CREATE ModelAction which created this Thread */ ModelAction *creation; + /** + * @brief The next ModelAction to be run by this Thread + * + * This action should be kept updated by the ModelChecker, so that we + * always know what the next ModelAction's memory_order, action type, + * and location are. + */ ModelAction *pending; + void (*start_routine)(void *); void *arg; ucontext_t context; @@ -148,7 +172,7 @@ Thread * thread_current(); static inline thread_id_t thrd_to_id(thrd_t t) { - return t; + return t.priv->get_id(); } /**