diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 058e44ebef..dff2717702 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -37,7 +37,7 @@ BUILD_ASSERT(K_LOWEST_APPLICATION_THREAD_PRIO #define Z_ASSERT_VALID_PRIO(prio, entry_point) __ASSERT((prio) == -1, "") #endif /* CONFIG_MULTITHREADING */ -extern struct k_thread _thread_dummy; +extern struct k_thread _thread_dummies[CONFIG_MP_MAX_NUM_CPUS]; void z_sched_init(void); void z_move_thread_to_end_of_prio_q(struct k_thread *thread); diff --git a/kernel/init.c b/kernel/init.c index e2dc36d46c..55f34ff973 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -650,7 +650,7 @@ FUNC_NORETURN void z_cstart(void) LOG_CORE_INIT(); #if defined(CONFIG_MULTITHREADING) - z_dummy_thread_init(&_thread_dummy); + z_dummy_thread_init(&_thread_dummies[0]); #endif /* CONFIG_MULTITHREADING */ /* do any necessary initialization of static devices */ z_device_state_init(); diff --git a/kernel/sched.c b/kernel/sched.c index 6f21ca5a80..1144db6cb3 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -33,7 +33,7 @@ struct k_spinlock _sched_spinlock; /* Storage to "complete" the context switch from an invalid/incomplete thread * context (ex: exiting an ISR that aborted _current) */ -__incoherent struct k_thread _thread_dummy; +__incoherent struct k_thread _thread_dummies[CONFIG_MP_MAX_NUM_CPUS]; static void update_cache(int preempt_ok); static void halt_thread(struct k_thread *thread, uint8_t new_state); @@ -1363,7 +1363,7 @@ static void halt_thread(struct k_thread *thread, uint8_t new_state) * code. */ if (dummify && !IS_ENABLED(CONFIG_ARCH_POSIX)) { - z_dummy_thread_init(&_thread_dummy); + z_dummy_thread_init(&_thread_dummies[_current_cpu->id]); } } } diff --git a/kernel/smp.c b/kernel/smp.c index 0aeaa69bf3..012faa71d6 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -122,7 +122,7 @@ static inline void smp_init_top(void *arg) /* Initialize the dummy thread struct so that * the scheduler can schedule actual threads to run. */ - z_dummy_thread_init(&_thread_dummy); + z_dummy_thread_init(&_thread_dummies[arch_curr_cpu()->id]); } #ifdef CONFIG_SYS_CLOCK_EXISTS