threads: construct Thread only with a given "parent"
authorBrian Norris <banorris@uci.edu>
Mon, 25 Feb 2013 23:15:28 +0000 (15:15 -0800)
committerBrian Norris <banorris@uci.edu>
Mon, 25 Feb 2013 23:15:28 +0000 (15:15 -0800)
The Thread constructor really doesn't need to call thread_current(),
since it will always be called from model-checker context. Clean up the
use of default "parent_thrd" parameter and just pass NULL when we have
no parent.

model.cc
threads-model.h
threads.cc

index 24eb83dbbc6515cb4c24730e27ee94c4c949afbe..436c337d3932f4d45a7d13ee0e8fe674d1a0ea9a 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -2890,7 +2890,7 @@ void ModelChecker::run()
 {
        do {
                thrd_t user_thread;
-               Thread *t = new Thread(&user_thread, &user_main_wrapper, NULL);
+               Thread *t = new Thread(&user_thread, &user_main_wrapper, NULL, NULL);
                add_thread(t);
 
                do {
index 30acd2deba1f50e27a15d1c2d74a649809cf004a..2cd09ab53739de7d327de3e5758af6b7ba66465d 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_thrd = NULL);
+       Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent);
        ~Thread();
        void complete();
 
@@ -128,7 +128,7 @@ private:
        int create_context();
 
        /** @brief The parent Thread which created this Thread */
-       Thread *parent;
+       Thread * const parent;
 
        /** @brief The THREAD_CREATE ModelAction which created this Thread */
        ModelAction *creation;
index cbedbb18bae1d73db1c46a531b4141886875b6be..762bbff34c2463a3dbaf6179e3af3e1eb977ca8b 100644 (file)
@@ -151,7 +151,8 @@ 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_thrd) :
+Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread *parent) :
+       parent(parent),
        creation(NULL),
        pending(NULL),
        start_routine(func),
@@ -171,7 +172,6 @@ Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread * parent_thrd) :
 
        id = model->get_next_id();
        user_thread->priv = this;
-       parent = parent_thrd ? parent_thrd : thread_current();
 }
 
 /** Destructor */