There may be points at which the user's thread ID struct goes out of scope, but
I still need it internally. I think I'll just keep it internally, with a
duplicate in the user's copy.
delete rootNode;
}
-void ModelChecker::assign_id(Thread *t)
+int ModelChecker::get_next_id()
{
- t->set_id(++used_thread_id);
+ return ++used_thread_id;
}
void ModelChecker::add_system_thread(Thread *t)
int add_thread(Thread *t);
Thread * get_thread(thread_id_t tid) { return thread_map[tid]; }
- void assign_id(Thread *t);
+ int get_next_id();
int switch_to_master(ModelAction *act);
printf("Error in create_context\n");
state = THREAD_CREATED;
- model->assign_id(this);
+ id = model->get_next_id();
+ *user_thread = id;
model->scheduler->add_thread(this);
}
arg = NULL;
state = THREAD_CREATED;
- model->assign_id(this);
+ id = model->get_next_id();
+ *user_thread = id;
create_context();
model->add_system_thread(this);
}
thread_id_t Thread::get_id()
{
- return thrd_to_id(*user_thread);
+ return id;
}
/*
thread_state get_state() { return state; }
void set_state(thread_state s) { state = s; }
thread_id_t get_id();
- void set_id(thread_id_t i) { *user_thread = i; }
thrd_t get_thrd_t() { return *user_thread; }
private:
int create_context();
ucontext_t context;
void *stack;
thrd_t *user_thread;
+ thread_id_t id;
thread_state state;
};