X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=threads.h;h=0f39a836f49efae34c63415f433e37715a43d258;hb=596b1d23fb2612df9ae569f17dbb3017a6e0aef7;hp=a97a04c704449963981fe443a711c64abc716fb3;hpb=ffc6c2cb448e419c73b8a7aa5a995b5f1a0a5e6e;p=c11tester.git diff --git a/threads.h b/threads.h index a97a04c7..0f39a836 100644 --- a/threads.h +++ b/threads.h @@ -13,10 +13,19 @@ typedef int thread_id_t; #define THREAD_ID_T_NONE -1 +/** @brief Represents the state of a user Thread */ typedef enum thread_state { + /** Thread was just created and hasn't run yet */ THREAD_CREATED, + /** Thread is running */ THREAD_RUNNING, + /** + * Thread has yielded to the model-checker but is ready to run. Used + * during an action that caused a context switch to the model-checking + * context. + */ THREAD_READY, + /** Thread has completed its execution */ THREAD_COMPLETED } thread_state; @@ -41,6 +50,21 @@ public: void set_creation(ModelAction *act) { creation = act; } ModelAction * get_creation() { return creation; } + /** + * Set a return value for the last action in this thread (e.g., for an + * atomic read). + * @param value The value to return + */ + void set_return_value(int value) { last_action_val = value; } + + /** + * Retrieve a return value for the last action in this thread. Used, + * for instance, for an atomic read to return the 'read' value. Should + * be called from a user context. + * @return The value 'returned' by the action + */ + int get_return_value() { return last_action_val; } + friend void thread_startup(); SNAPSHOTALLOC @@ -56,6 +80,13 @@ private: thrd_t *user_thread; thread_id_t id; thread_state state; + + /** + * The value returned by the last action in this thread + * @see Thread::set_return_value() + * @see Thread::get_return_value() + */ + int last_action_val; }; Thread * thread_current();