From db1448b21a253cf3ac1bd4899da3006eb7e4d58b Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 26 Jan 2021 22:45:30 -0700 Subject: [PATCH] Kernel: Add a compile-time switch to enable scheduling on all CPUs This is meant to be temporary only and should be removed once scheduling on all CPUs is stable. --- Kernel/Scheduler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 35cd15181a..3b393c8dda 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -36,6 +36,9 @@ #include #include +// Remove this once SMP is stable and can be enabled by default +#define SCHEDULE_ON_ALL_PROCESSORS 0 + namespace Kernel { class SchedulerPerProcessorData { @@ -550,9 +553,11 @@ void Scheduler::timer_tick(const RegisterState& regs) ASSERT(current_thread->current_trap()); ASSERT(current_thread->current_trap()->regs == ®s); +#if !SCHEDULE_ON_ALL_PROCESSORS bool is_bsp = Processor::id() == 0; if (!is_bsp) return; // TODO: This prevents scheduling on other CPUs! +#endif if (current_thread->process().is_profiling()) { ASSERT(current_thread->process().perf_events()); auto& perf_events = *current_thread->process().perf_events(); @@ -616,8 +621,12 @@ void Scheduler::idle_loop(void*) proc.idle_end(); ASSERT_INTERRUPTS_ENABLED(); +#if SCHEDULE_ON_ALL_PROCESSORS + yield(); +#else if (Processor::current().id() == 0) yield(); +#endif } }