case THREAD_CREATE: {
thrd_t *thrd = (thrd_t *)curr->get_location();
struct thread_params *params = (struct thread_params *)curr->get_value();
- Thread *th = new Thread(thrd, params->func, params->arg, get_thread(curr));
+ Thread *th = new Thread(get_next_id(), thrd, params->func, params->arg, get_thread(curr));
add_thread(th);
th->set_creation(curr);
/* Promises can be satisfied by children */
{
do {
thrd_t user_thread;
- Thread *t = new Thread(&user_thread, &user_main_wrapper, NULL, NULL);
+ Thread *t = new Thread(execution->get_next_id(), &user_thread, &user_main_wrapper, NULL, NULL);
execution->add_thread(t);
do {
bool is_enabled(Thread *t) const;
bool is_enabled(thread_id_t tid) const;
- thread_id_t get_next_id();
unsigned int get_num_threads() const;
Thread * get_current_thread() const;
class Thread {
public:
Thread(thread_id_t tid);
- Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent);
+ Thread(thread_id_t tid, thrd_t *t, void (*func)(void *), void *a, Thread *parent);
~Thread();
void complete();
* @param func The function that the thread will call.
* @param a The parameter to pass to this function.
*/
-Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent) :
+Thread::Thread(thread_id_t tid, thrd_t *t, void (*func)(void *), void *a, Thread *parent) :
parent(parent),
creation(NULL),
pending(NULL),
start_routine(func),
arg(a),
user_thread(t),
+ id(tid),
state(THREAD_CREATED),
last_action_val(VALUE_NONE),
model_thread(false)
if (ret)
model_print("Error in create_context\n");
- id = model->get_next_id();
user_thread->priv = this;
}