threads: add constructor for model-checker thread
authorBrian Norris <banorris@uci.edu>
Sat, 6 Oct 2012 00:50:37 +0000 (17:50 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 05:22:52 +0000 (22:22 -0700)
This thread will never have its own stack, and it should never be
inserted into the Scheduler.

threads.cc
threads.h

index e1f74bfbd210da803259b09300ca15f5db3f964e..7f515159f78052727180b1be6d82ba1df7e9ebac 100644 (file)
@@ -2,6 +2,8 @@
  *  @brief Thread functions.
  */
 
+#include <string.h>
+
 #include "libthreads.h"
 #include "common.h"
 #include "threads.h"
@@ -112,6 +114,31 @@ void Thread::complete()
        }
 }
 
+/**
+ * @brief Construct a new model-checker Thread
+ *
+ * A model-checker Thread is used for accounting purposes only. It will never
+ * have its own stack, and it should never be inserted into the Scheduler.
+ *
+ * @param tid The thread ID to assign
+ */
+Thread::Thread(thread_id_t tid) :
+       parent(NULL),
+       creation(NULL),
+       pending(NULL),
+       start_routine(NULL),
+       arg(NULL),
+       stack(NULL),
+       user_thread(NULL),
+       id(tid),
+       state(THREAD_READY), /* Thread is always ready? */
+       wait_list(),
+       last_action_val(0),
+       model_thread(true)
+{
+       memset(&context, 0, sizeof(context));
+}
+
 /**
  * Construct a new thread.
  * @param t The thread identifier of the newly created thread.
index 5e8cbef50a95648f2b6ac35069620b44b4e433a8..7f005c078c0c126edfcb5f48af6f220a65b3798b 100644 (file)
--- a/threads.h
+++ b/threads.h
@@ -35,6 +35,7 @@ class ModelAction;
 /** @brief A Thread is created for each user-space thread */
 class Thread {
 public:
+       Thread(thread_id_t tid);
        Thread(thrd_t *t, void (*func)(void *), void *a);
        ~Thread();
        void complete();