fixes for A2
mostly include some things that should and remove some things that shouldn't have been included in the handout (yes this does hint at some places that need to be touched for A2)
This commit is contained in:
@@ -32,15 +32,13 @@ void Scheduler::resume(bool ready) {
|
||||
Thread *me = dispatcher.active();
|
||||
assert(me != nullptr && "Pointer to active thread should never be nullptr");
|
||||
|
||||
if (true) {
|
||||
// Be careful, never put the idle thread into the ready list
|
||||
bool is_idle_thread = static_cast<Thread *>(&idleThread) == me;
|
||||
// Be careful, never put the idle thread into the ready list
|
||||
bool is_idle_thread = static_cast<Thread *>(&idleThread) == me;
|
||||
|
||||
if (ready && readylist.is_empty()) {
|
||||
return;
|
||||
} else if (!is_idle_thread) {
|
||||
if (ready) readylist.enqueue(*me);
|
||||
}
|
||||
if (ready && readylist.is_empty()) {
|
||||
return;
|
||||
} else if (!is_idle_thread) {
|
||||
if (ready) readylist.enqueue(*me);
|
||||
}
|
||||
|
||||
dispatcher.dispatch(getNext());
|
||||
@@ -56,6 +54,8 @@ void Scheduler::kill(Thread *that) {
|
||||
if (dispatcher.active() == that) {
|
||||
exit();
|
||||
}
|
||||
|
||||
readylist.remove(that);
|
||||
}
|
||||
|
||||
bool Scheduler::isEmpty() const { return readylist.is_empty(); }
|
||||
|
||||
Reference in New Issue
Block a user