From 6eaa3223d190e5119cb686d91896576e6d166caf Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 15 Jun 2026 19:31:35 -0300 Subject: [PATCH] scheduler: pick cpus properly in pick_cpu when system is not fully up yet --- kernel-src/sys/scheduler/queue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel-src/sys/scheduler/queue.c b/kernel-src/sys/scheduler/queue.c index 51f39c39..20d8bf85 100644 --- a/kernel-src/sys/scheduler/queue.c +++ b/kernel-src/sys/scheduler/queue.c @@ -9,9 +9,9 @@ bitmap_t sched_idle_cpu_bitmap; spinlock_t sched_idle_cpu_bitmap_lock; static cpu_t *pick_cpu(thread_t *thread) { - // if there is only one cpu awake, thats the current one - if (arch_smp_cpusawake == 1) - return current_cpu(); + // if the system is still being bootstrapped or it is a single core machine, run it on the BSP + if (arch_smp_get_cpu_count() == 1 || unlikely(arch_smp_cpusawake != arch_smp_get_cpu_count())) + return get_bsp(); // if the thread targets a specific cpu, then go into that if (thread->cputarget)