diff options
author | Tom <tomut@yahoo.com> | 2020-10-28 16:06:16 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-27 22:48:41 +0100 |
commit | c53108487331a579a3be9b43ec60d6e73cee26ed (patch) | |
tree | 4f8afb687d69c27a71e7b5a674d6cc9e10dbc33c /Kernel/Scheduler.cpp | |
parent | 39f408daa01bcf6a738becd8b46b44aba051749b (diff) | |
download | serenity-c53108487331a579a3be9b43ec60d6e73cee26ed.zip |
Kernel: Track processor idle state and wake processors when waking threads
Attempt to wake idle processors to get threads to be scheduled more quickly.
We don't want to wait until the next timer tick if we have processors that
aren't doing anything.
Diffstat (limited to 'Kernel/Scheduler.cpp')
-rw-r--r-- | Kernel/Scheduler.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 1fd17e1ae7..5c0eb58506 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -544,13 +544,17 @@ void Scheduler::notify_finalizer() void Scheduler::idle_loop(void*) { - dbgln("Scheduler[{}]: idle loop running", Processor::id()); + auto& proc = Processor::current(); + dbgln("Scheduler[{}]: idle loop running", proc.get_id()); ASSERT(are_interrupts_enabled()); for (;;) { + proc.idle_begin(); asm("hlt"); - if (Processor::id() == 0) + proc.idle_end(); + ASSERT_INTERRUPTS_ENABLED(); + if (Processor::current().id() == 0) yield(); } } |