diff options
author | Tom <tomut@yahoo.com> | 2020-10-25 22:02:14 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-26 08:57:25 +0100 |
commit | 3ffdaabe10c569e73b9c5d4bf5da200e1f749f64 (patch) | |
tree | 14780dacb66c46d63cc13461def224c038e4d1a7 | |
parent | 1e2e3eed62377b207b4912ce76870a28163e3482 (diff) | |
download | serenity-3ffdaabe10c569e73b9c5d4bf5da200e1f749f64.zip |
Kernel: Only consider scheduler Running threads if they're the current
There will be as many threads in Running state as there are CPUs.
Only consider a thread in that state if it is the current thread
already.
-rw-r--r-- | Kernel/Scheduler.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index e3e27900e5..2b91bad29c 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -465,8 +465,8 @@ bool Scheduler::pick_next() }); #ifdef SCHEDULER_RUNNABLE_DEBUG - dbg() << "Non-runnables:"; - Scheduler::for_each_nonrunnable([](Thread& thread) -> IterationDecision { + dbg() << "Scheduler[" << Processor::current().id() << "]: Non-runnables:"; + Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision { if (thread.state() == Thread::Queued) dbg() << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip) << " Reason: " << (thread.wait_reason() ? thread.wait_reason() : "none"); else if (thread.state() == Thread::Dying) @@ -476,7 +476,7 @@ bool Scheduler::pick_next() return IterationDecision::Continue; }); - dbg() << "Runnables:"; + dbg() << "Scheduler[" << Processor::current().id() << "]: Runnables:"; Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision { dbg() << " " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip); return IterationDecision::Continue; @@ -487,8 +487,11 @@ bool Scheduler::pick_next() Vector<Thread*, 128> sorted_runnables; for_each_runnable([&](auto& thread) { - if ((thread.affinity() & (1u << Processor::current().id())) != 0) - sorted_runnables.append(&thread); + if ((thread.affinity() & (1u << Processor::current().id())) == 0) + return IterationDecision::Continue; + if (thread.state() == Thread::Running && &thread != current_thread) + return IterationDecision::Continue; + sorted_runnables.append(&thread); if (&thread == scheduler_data.m_pending_beneficiary) { thread_to_schedule = &thread; return IterationDecision::Break; |