smp: fix race between cpu exposure and smp init

The SMP code exposes that a cpu woke up before it is properly
initialized in sched_ap_entry(). Fix this by initializing it first,
exposing it and then stopping the bootstrap thread.
This commit is contained in:
Matheus
2026-10-06 10:26:56 -03:00
parent 1ed159489d
commit 0cdd03eba8
2 changed files with 4 additions and 2 deletions
+4 -1
View File
@@ -50,8 +50,11 @@ static void cpuwakeup(struct limine_mp_info *info) {
arch_profiling_init();
#endif
__atomic_add_fetch(&arch_smp_cpusawake, 1, __ATOMIC_SEQ_CST);
sched_ap_entry();
__atomic_add_fetch(&arch_smp_cpusawake, 1, __ATOMIC_SEQ_CST);
sched_stop_current_thread();
}
void arch_smp_send_ipi(cpu_t *targcpu, isr_t *isr, int target, bool nmi) {
-1
View File
@@ -376,7 +376,6 @@ void sched_ap_entry() {
timer_insert(current_cpu()->timer, &current_cpu()->schedtimerentry, reschedule_timer_dpc, NULL, QUANTUM_US, true);
timer_insert(current_cpu()->timer, &current_cpu()->calendar_tick_timer_entry, sched_calendar_tick, NULL, 10000, true);
timer_resume(current_cpu()->timer);
sched_stop_current_thread();
}
void sched_init() {