mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
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:
@@ -50,8 +50,11 @@ static void cpuwakeup(struct limine_mp_info *info) {
|
|||||||
arch_profiling_init();
|
arch_profiling_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__atomic_add_fetch(&arch_smp_cpusawake, 1, __ATOMIC_SEQ_CST);
|
|
||||||
sched_ap_entry();
|
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) {
|
void arch_smp_send_ipi(cpu_t *targcpu, isr_t *isr, int target, bool nmi) {
|
||||||
|
|||||||
@@ -376,7 +376,6 @@ void sched_ap_entry() {
|
|||||||
timer_insert(current_cpu()->timer, ¤t_cpu()->schedtimerentry, reschedule_timer_dpc, NULL, QUANTUM_US, true);
|
timer_insert(current_cpu()->timer, ¤t_cpu()->schedtimerentry, reschedule_timer_dpc, NULL, QUANTUM_US, true);
|
||||||
timer_insert(current_cpu()->timer, ¤t_cpu()->calendar_tick_timer_entry, sched_calendar_tick, NULL, 10000, true);
|
timer_insert(current_cpu()->timer, ¤t_cpu()->calendar_tick_timer_entry, sched_calendar_tick, NULL, 10000, true);
|
||||||
timer_resume(current_cpu()->timer);
|
timer_resume(current_cpu()->timer);
|
||||||
sched_stop_current_thread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sched_init() {
|
void sched_init() {
|
||||||
|
|||||||
Reference in New Issue
Block a user