From f19a959f1a76e35316df4b8dce39d17640305417 Mon Sep 17 00:00:00 2001
From: Brian Norris <banorris@uci.edu>
Date: Wed, 19 Dec 2012 16:50:11 -0800
Subject: [PATCH] model: use get_thread(curr) instead of get_current_thread()

The former is more accurate; the latter is only intended for use while
in user-thread context, where we are sure that Scheduler is in the
appropriate state.
---
 model.cc | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/model.cc b/model.cc
index c9bb868..14b1aa3 100644
--- a/model.cc
+++ b/model.cc
@@ -174,7 +174,12 @@ unsigned int ModelChecker::get_num_threads() const
 	return priv->next_thread_id;
 }
 
-/** @return The currently executing Thread. */
+/**
+ * Must be called from user-thread context (e.g., through the global
+ * thread_current() interface)
+ *
+ * @return The currently executing Thread.
+ */
 Thread * ModelChecker::get_current_thread() const
 {
 	return scheduler->get_current_thread();
@@ -820,7 +825,7 @@ bool ModelChecker::process_mutex(ModelAction *curr)
 		if (curr->get_node()->get_misc() == 0) {
 			get_safe_ptr_action(condvar_waiters_map, curr->get_location())->push_back(curr);
 			//disable us
-			scheduler->sleep(get_current_thread());
+			scheduler->sleep(get_thread(curr));
 		}
 		break;
 	}
@@ -1203,8 +1208,8 @@ ModelAction * ModelChecker::check_current_action(ModelAction *curr)
 	if (!check_action_enabled(curr)) {
 		/* Make the execution look like we chose to run this action
 		 * much later, when a lock/join can succeed */
-		get_current_thread()->set_pending(curr);
-		scheduler->sleep(get_current_thread());
+		get_thread(curr)->set_pending(curr);
+		scheduler->sleep(get_thread(curr));
 		return NULL;
 	}
 
-- 
2.34.1