model / threads: remove global get_next_id() interface
authorBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 02:31:58 +0000 (19:31 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 02:31:58 +0000 (19:31 -0700)
execution.cc
model.cc
model.h
threads-model.h
threads.cc

index 0ec1390..fe9175b 100644 (file)
@@ -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 */
index 5594973..03d7ba3 100644 (file)
--- 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 4dbe557..be53ec3 100644 (file)
--- 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;
 
index 5fc6d67..733d825 100644 (file)
@@ -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();
 
index ae2905a..a0bc029 100644 (file)
@@ -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;
 }