From: Derek Yeh Date: Fri, 7 Aug 2020 00:14:25 +0000 (-0700) Subject: fix getNextThread func X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=f820ef3caa1dc1a5bd935f901d7bc9c1f653e423 fix getNextThread func --- diff --git a/model.cc b/model.cc index 170edc74..ac394d9a 100644 --- a/model.cc +++ b/model.cc @@ -366,13 +366,14 @@ void ModelChecker::continueExecution(Thread *old) Thread* ModelChecker::getNextThread() { - Thread *thr = nullptr; + Thread *nextThread = nullptr; for (unsigned int i = curr_thread_num; i < get_num_threads(); i++) { thread_id_t tid = int_to_id(i); - thr = get_thread(tid); + Thread *thr = get_thread(tid); if (!thr->is_complete() && !thr->get_pending()) { curr_thread_num = i; + nextThread = thr; break; } ModelAction *act = thr->get_pending(); @@ -383,7 +384,7 @@ Thread* ModelChecker::getNextThread() chooseThread(act, thr); } - return thr; + return nextThread; } void ModelChecker::finishExecution(Thread *old) @@ -537,7 +538,12 @@ void ModelChecker::run() curr_thread_num = 1; thread_id_t tid = int_to_id(1); Thread *thr = get_thread(tid); - switch_from_master(thr); + if (!thr->get_pending()) + switch_from_master(thr); + else { + consumeAction(); + switch_from_master(thr); + } finish_execution((exec+1) < params.maxexecutions); //restore random number generator state after rollback setstate(random_state);