action: add THREAD_FINISH action
authorBrian Norris <banorris@uci.edu>
Thu, 6 Sep 2012 20:07:26 +0000 (13:07 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 6 Sep 2012 20:07:26 +0000 (13:07 -0700)
For cleanly finalizing a thread.

action.cc
action.h
threads.cc

index 692d14c..205bedb 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -218,6 +218,9 @@ void ModelAction::print(void) const
        case THREAD_JOIN:
                type_str = "thread join";
                break;
+       case THREAD_FINISH:
+               type_str = "thread finish";
+               break;
        case ATOMIC_READ:
                type_str = "atomic read";
                break;
index 6559928..3e590aa 100644 (file)
--- a/action.h
+++ b/action.h
@@ -32,6 +32,7 @@ typedef enum action_type {
        THREAD_START,         /**< First action in each thread */
        THREAD_YIELD,         /**< A thread yield action */
        THREAD_JOIN,          /**< A thread join action */
+       THREAD_FINISH,        /**< A thread completion action */
        ATOMIC_READ,          /**< An atomic read action */
        ATOMIC_WRITE,         /**< An atomic write action */
        ATOMIC_RMWR,          /**< The read part of an atomic RMW action */
index 9b7954d..b3a1d55 100644 (file)
@@ -44,6 +44,9 @@ void thread_startup()
 
        /* Call the actual thread function */
        curr_thread->start_routine(curr_thread->arg);
+
+       /* Finish thread properly */
+       model->switch_to_master(new ModelAction(THREAD_FINISH, std::memory_order_seq_cst, curr_thread));
 }
 
 /**