From f472540b6ab3b65c91221f6f0790d8327333a5c2 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 6 Sep 2012 13:07:26 -0700 Subject: [PATCH] action: add THREAD_FINISH action For cleanly finalizing a thread. --- action.cc | 3 +++ action.h | 1 + threads.cc | 3 +++ 3 files changed, 7 insertions(+) diff --git a/action.cc b/action.cc index 692d14c..205bedb 100644 --- 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; diff --git a/action.h b/action.h index 6559928..3e590aa 100644 --- 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 */ diff --git a/threads.cc b/threads.cc index 9b7954d..b3a1d55 100644 --- a/threads.cc +++ b/threads.cc @@ -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)); } /** -- 2.34.1