model: implement, use schedule_next_thread()
authorBrian Norris <banorris@uci.edu>
Fri, 20 Apr 2012 17:50:29 +0000 (10:50 -0700)
committerBrian Norris <banorris@uci.edu>
Fri, 20 Apr 2012 17:58:22 +0000 (10:58 -0700)
Relies on the rest of the model checker to set the next thread; simply returns
the chosen thread.

model.cc
schedule.cc

index 4307b392b3e15c6be1e837d07a9baae31aaee3e0..26fd6cae0c6f33b04c3c2e3139f8bdc03f56565c 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -39,6 +39,17 @@ void ModelChecker::add_system_thread(Thread *t)
        this->system_thread = t;
 }
 
+Thread *ModelChecker::schedule_next_thread()
+{
+       Thread *t;
+       if (nextThread == THREAD_ID_T_NONE)
+               return NULL;
+       t = thread_map[nextThread];
+       if (t == NULL)
+               DEBUG("*** error: thread not in thread_map: id = %d\n", nextThread);
+       return t;
+}
+
 ModelAction *ModelChecker::get_last_conflict(ModelAction *act)
 {
        void *loc = act->get_location();
index 04328252da0c8dbbf1452e4b7cd6d091c14a7116..13b640cd8e832b2cca826e5a4b68d66143bb854c 100644 (file)
@@ -11,6 +11,12 @@ void Scheduler::add_thread(Thread *t)
 
 Thread *Scheduler::next_thread(void)
 {
+       Thread *t = model->schedule_next_thread();
+
+       if (t != NULL) {
+               readyList.remove(t);
+               return t;
+       }
        if (readyList.empty())
                return NULL;