Kernel: Schedule threads on all processors when SMP is enabled

Note that SMP is still off by default, but this basically removes the
weird "SMP on but threads don't get scheduled" behavior we had by
default. If you pass "smp=on" to the kernel, you now get SMP. :^)
This commit is contained in:
Andreas Kling 2022-08-18 18:56:50 +02:00
parent b560442fe1
commit c3ad4ffcec
Notes: sideshowbarker 2024-07-17 23:02:37 +09:00

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -20,9 +20,6 @@
#include <Kernel/Time/TimeManagement.h>
#include <Kernel/kstdio.h>
// Remove this once SMP is stable and can be enabled by default
#define SCHEDULE_ON_ALL_PROCESSORS 0
namespace Kernel {
RecursiveSpinlock g_scheduler_lock;
@ -451,11 +448,6 @@ void Scheduler::timer_tick(RegisterState const& regs)
VERIFY(current_thread->current_trap());
VERIFY(current_thread->current_trap()->regs == &regs);
#if !SCHEDULE_ON_ALL_PROCESSORS
if (!Processor::is_bootstrap_processor())
return; // TODO: This prevents scheduling on other CPUs!
#endif
if (current_thread->process().is_kernel_process()) {
// Because the previous mode when entering/exiting kernel threads never changes
// we never update the time scheduled. So we need to update it manually on the
@ -519,12 +511,7 @@ void Scheduler::idle_loop(void*)
proc.idle_end();
VERIFY_INTERRUPTS_ENABLED();
#if SCHEDULE_ON_ALL_PROCESSORS
yield();
#else
if (Processor::current_id() == 0)
yield();
#endif
}
}