7 Scheduler::Scheduler() :
13 * Add a Thread to the scheduler's ready list.
14 * @param t The Thread to add
16 void Scheduler::add_thread(Thread *t)
18 DEBUG("thread %d\n", t->get_id());
19 readyList.push_back(t);
23 * Remove a given Thread from the scheduler.
24 * @param t The Thread to remove
26 void Scheduler::remove_thread(Thread *t)
35 * Remove one Thread from the scheduler. This implementation defaults to FIFO,
36 * if a thread is not already provided.
38 * @param t Thread to run, if chosen by an external entity (e.g.,
39 * ModelChecker). May be NULL to indicate no external choice.
40 * @return The next Thread to run
42 Thread * Scheduler::next_thread(Thread *t)
47 } else if (readyList.empty()) {
50 t = readyList.front();
52 readyList.pop_front();
61 * @return The currently-running Thread
63 Thread * Scheduler::get_current_thread() const
69 * Print debugging information about the current state of the scheduler. Only
70 * prints something if debugging is enabled.
72 void Scheduler::print() const
75 DEBUG("Current thread: %d\n", current->get_id());
77 DEBUG("No current thread\n");
78 DEBUG("Num. threads in ready list: %zu\n", readyList.size());
80 std::list<Thread *, MyAlloc< Thread * > >::const_iterator it;
81 for (it = readyList.begin(); it != readyList.end(); it++)
82 DEBUG("In ready list: thread %d\n", (*it)->get_id());