2 * @brief Model Checker Thread class.
10 #include "libthreads.h"
12 typedef int thread_id_t;
14 #define THREAD_ID_T_NONE -1
16 typedef enum thread_state {
25 /** @brief A Thread is created for each user-space thread */
28 Thread(thrd_t *t, void (*func)(void *), void *a);
32 static int swap(ucontext_t *ctxt, Thread *t);
33 static int swap(Thread *t, ucontext_t *ctxt);
35 thread_state get_state() { return state; }
36 void set_state(thread_state s) { state = s; }
38 thrd_t get_thrd_t() { return *user_thread; }
39 Thread * get_parent() { return parent; }
41 void set_creation(ModelAction *act) { creation = act; }
42 ModelAction * get_creation() { return creation; }
45 * Set a return value for the last action in this thread (e.g., for an
47 * @param value The value to return
49 void set_return_value(int value) { last_action_val = value; }
52 * Retrieve a return value for the last action in this thread. Used,
53 * for instance, for an atomic read to return the 'read' value. Should
54 * be called from a user context.
55 * @return The value 'returned' by the action
57 int get_return_value() { return last_action_val; }
59 friend void thread_startup();
65 ModelAction *creation;
67 void (*start_routine)(void *);
76 * The value returned by the last action in this thread
77 * @see Thread::set_return_value()
78 * @see Thread::get_return_value()
83 Thread * thread_current();
85 static inline thread_id_t thrd_to_id(thrd_t t)
90 static inline thread_id_t int_to_id(int i)
95 static inline int id_to_int(thread_id_t id)
100 #endif /* __THREADS_H__ */