From a6ce579c6437ebead8fee2c8df1530d223591318 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 15 Apr 2013 19:31:58 -0700 Subject: [PATCH] model / threads: remove global get_next_id() interface --- execution.cc | 2 +- model.cc | 2 +- model.h | 1 - threads-model.h | 2 +- threads.cc | 4 ++-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/execution.cc b/execution.cc index 0ec13900..fe9175b2 100644 --- a/execution.cc +++ b/execution.cc @@ -911,7 +911,7 @@ bool ModelExecution::process_thread_action(ModelAction *curr) 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 */ diff --git a/model.cc b/model.cc index 55949730..03d7ba33 100644 --- a/model.cc +++ b/model.cc @@ -436,7 +436,7 @@ void ModelChecker::run() { 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 { diff --git a/model.h b/model.h index 4dbe5572..be53ec3f 100644 --- a/model.h +++ b/model.h @@ -58,7 +58,6 @@ public: 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; diff --git a/threads-model.h b/threads-model.h index 5fc6d675..733d825f 100644 --- a/threads-model.h +++ b/threads-model.h @@ -41,7 +41,7 @@ class ModelAction; 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(); diff --git a/threads.cc b/threads.cc index ae2905a9..a0bc0297 100644 --- a/threads.cc +++ b/threads.cc @@ -151,13 +151,14 @@ Thread::Thread(thread_id_t tid) : * @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) @@ -169,7 +170,6 @@ Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent) : if (ret) model_print("Error in create_context\n"); - id = model->get_next_id(); user_thread->priv = this; } -- 2.34.1