model: use get_thread(curr) instead of get_current_thread()
authorBrian Norris <banorris@uci.edu>
Thu, 20 Dec 2012 00:50:11 +0000 (16:50 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 2 Jan 2013 22:14:20 +0000 (14:14 -0800)
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

index c9bb86824233723fc706ba2ae8b407f14a5c8895..14b1aa38b500a146e49b2766e54509afcb029c99 100644 (file)
--- 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;
        }