From 28a8923983a54f838c7a1667795d37c1d801877c Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 2 Oct 2012 17:14:46 -0700 Subject: [PATCH] model: refactor mutex thread-blocking code There are a few functions that are used in suboptimal ways. * use the ModelChecker::get_thread(ModelAction *) version of overloaded 'get_thread()' function * the add/remove interfaces were used inconsistently previously; for "waking" we directly utilized Scheduler::add_thread, whereas the "sleeping" case used ModelChecker::remove_thread * use the Scheduler::sleep and Scheduler::wake functions for sleep/wake instead of explicitly adding/removing --- model.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.cc b/model.cc index 40519e5..2c5ad5a 100644 --- a/model.cc +++ b/model.cc @@ -426,7 +426,7 @@ bool ModelChecker::process_mutex(ModelAction *curr) { action_list_t *waiters = lock_waiters_map->get_safe_ptr(curr->get_location()); //activate all the waiting threads for (action_list_t::iterator rit = waiters->begin(); rit != waiters->end(); rit++) { - scheduler->add_thread(get_thread((*rit)->get_tid())); + scheduler->wake(get_thread(*rit)); } waiters->clear(); break; @@ -615,7 +615,7 @@ Thread * ModelChecker::check_current_action(ModelAction *curr) /* Make the execution look like we chose to run this action * much later, when a lock is actually available to release */ get_current_thread()->set_pending(curr); - remove_thread(get_current_thread()); + scheduler->sleep(get_current_thread()); return get_next_thread(NULL); } -- 2.34.1