This commit is contained in:
Niklas Gollenstede
2025-10-31 22:37:36 +01:00
commit 174fe17e89
197 changed files with 79558 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#include "idlethread.h"
#include "../arch/core.h"
#include "../arch/lapic.h"
#include "../debug/output.h"
#include "../interrupt/guard.h"
#include "../thread/scheduler.h"
void IdleThread::action() {
while (true) {
Core::Interrupt::disable();
if (Guard::unsafeConstAccess()
.scheduler.isEmpty()) { // XXX: not a fan ...
// To save energy we can disable the timer on a core as soon as no
// clock needs to be managed. This function is called from the idle
// loop.
bool can_sleep =
!Guard::unsafeConstAccess().bellringer.bellPending();
if (can_sleep) {
LAPIC::Timer::setMasked(true);
}
Core::idle();
// We woke up. Start ticking again
LAPIC::Timer::setMasked(false);
} else {
Core::Interrupt::enable();
Guarded g = Guard::enter();
g.vault().scheduler.resume();
}
}
}