diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-14 19:44:22 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-14 20:21:10 +0200 |
commit | e1481dcb4227066974aeee49fcb349ae5c0eee4a (patch) | |
tree | 8b681edee14306dbe93fae9148a6877b9b5f9197 /Kernel/Scheduler.cpp | |
parent | b35ad5b523ec8fcb2f247c1c6700af2a244115b7 (diff) | |
download | serenity-e1481dcb4227066974aeee49fcb349ae5c0eee4a.zip |
Kernel: Stop idling after handling an IRQ
If we receive an IRQ while the idle task is running, prevent it from
re-halting the CPU after the IRQ handler returns.
Instead have the idle task yield to the scheduler, so we can see if
the IRQ has unblocked something.
Diffstat (limited to 'Kernel/Scheduler.cpp')
-rw-r--r-- | Kernel/Scheduler.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index ed5ce0eb0c..310f9c2d14 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -575,3 +575,24 @@ void Scheduler::timer_tick(RegisterDump& regs) "orl $0x00004000, (%esp)\n" "popf\n"); } + +static bool s_should_stop_idling = false; + +void Scheduler::stop_idling() +{ + if (current != &s_colonel_process->main_thread()) + return; + + s_should_stop_idling = true; +} + +void Scheduler::idle_loop() +{ + for (;;) { + asm("hlt"); + if (s_should_stop_idling) { + s_should_stop_idling = false; + yield(); + } + } +} |