action / threads: add THREAD_START action at start of each thread
authorBrian Norris <banorris@uci.edu>
Wed, 11 Jul 2012 21:52:56 +0000 (14:52 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 11 Jul 2012 21:52:56 +0000 (14:52 -0700)
The datarace code needs every thread to have at least one action in it, so that
the action has a valid non-zero clock.

action.cc
action.h
threads.cc

index 44d3f8f1d9b3e701e5d38f7100611b00b6870cf8..d9aae2d4958253977e9f0256fb87076174e94a67 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -153,6 +153,9 @@ void ModelAction::print(void) const
        case THREAD_CREATE:
                type_str = "thread create";
                break;
+       case THREAD_START:
+               type_str = "thread start";
+               break;
        case THREAD_YIELD:
                type_str = "thread yield";
                break;
index 00bb5c2fbdef9c2a2a77729ed16e3b386eca74c9..3e4480419c03941413307ebba6a6e27a77372109 100644 (file)
--- a/action.h
+++ b/action.h
@@ -19,6 +19,7 @@
  * ModelAction */
 typedef enum action_type {
        THREAD_CREATE,        /**< A thread creation action */
+       THREAD_START,         /**< First action in each thread */
        THREAD_YIELD,         /**< A thread yield action */
        THREAD_JOIN,          /**< A thread join action */
        ATOMIC_READ,          /**< An atomic read action */
index ba7b54730781369fd6c17ec9f4bc492d660b3843..6a9391f0302467097b415bf4b129eb1b90fffaa5 100644 (file)
@@ -23,10 +23,18 @@ Thread * thread_current(void)
        return model->scheduler->get_current_thread();
 }
 
-/* This method just gets around makecontext not being 64-bit clean */
-
+/**
+ * Provides a startup wrapper for each thread, allowing some initial
+ * model-checking data to be recorded. This method also gets around makecontext
+ * not being 64-bit clean
+ */
 void thread_startup() {
        Thread * curr_thread = thread_current();
+
+       /* Add dummy "start" action, just to create a first clock vector */
+       model->switch_to_master(new ModelAction(THREAD_START, memory_order_seq_cst, curr_thread));
+
+       /* Call the actual thread function */
        curr_thread->start_routine(curr_thread->arg);
 }