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 692d14cf03033d4b3c89ed7e05a7d386acdfe352..205bedbf6f12806835a503975e95709162630070 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 6559928b14f6131489fe0c1e6ddc508e28a58ae5..3e590aae7f34a115cefb9fafed941a91d3bc5f92 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 9b7954d9386b6f5390ed42a32b43a53f5f5f1ca7..b3a1d5599fb541d340184e0e2ba0f7589c0ec5ae 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));
 }
 
 /**