model: implement, use schedule_next_thread()
[model-checker.git] / schedule.cc
index 691c6f43088595300ac198783328d4b102c8b0f4..13b640cd8e832b2cca826e5a4b68d66143bb854c 100644 (file)
@@ -6,16 +6,22 @@
 void Scheduler::add_thread(Thread *t)
 {
        DEBUG("thread %d\n", t->get_id());
-       queue.push(t);
+       readyList.push_back(t);
 }
 
 Thread *Scheduler::next_thread(void)
 {
-       if (queue.empty())
+       Thread *t = model->schedule_next_thread();
+
+       if (t != NULL) {
+               readyList.remove(t);
+               return t;
+       }
+       if (readyList.empty())
                return NULL;
 
-       current = queue.front();
-       queue.pop();
+       current = readyList.front();
+       readyList.pop_front();
 
        return current;
 }