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:
Niklas Gollenstede
2025-11-24 15:04:26 +01:00
parent 174fe17e89
commit 4245798955
18 changed files with 186 additions and 3300 deletions

View File

@@ -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(); }