From c24673eefc5f5404a25ec1c5bef6e620499eebcb Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Mon, 16 Mar 2020 09:44:28 -0700 Subject: [PATCH] kernel: properly name idle threads These are now indexed by CPU. Signed-off-by: Andrew Boie --- kernel/init.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index 8d2dd3e6d2..8ae3df128f 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -35,7 +35,6 @@ #include #include -#define IDLE_THREAD_NAME "idle" #define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL #include LOG_MODULE_REGISTER(os); @@ -280,11 +279,22 @@ void __weak main(void) /* LCOV_EXCL_STOP */ #if defined(CONFIG_MULTITHREADING) -static void init_idle_thread(struct k_thread *thread, k_thread_stack_t *stack) +static void init_idle_thread(int i) { + struct k_thread *thread = &z_idle_threads[i]; + k_thread_stack_t *stack = z_idle_stacks[i]; + +#ifdef CONFIG_THREAD_NAME + char tname[8]; + + snprintk(tname, 8, "idle %02d", i); +#else + char *tname = NULL; +#endif /* CONFIG_THREAD_NAME */ + z_setup_new_thread(thread, stack, CONFIG_IDLE_STACK_SIZE, idle, NULL, NULL, NULL, - K_LOWEST_THREAD_PRIO, K_ESSENTIAL, IDLE_THREAD_NAME); + K_LOWEST_THREAD_PRIO, K_ESSENTIAL, tname); z_mark_thread_as_started(thread); #ifdef CONFIG_SMP @@ -354,7 +364,7 @@ static void prepare_multithreading(struct k_thread *dummy_thread) z_ready_thread(&z_main_thread); for (int i = 0; i < CONFIG_MP_NUM_CPUS; i++) { - init_idle_thread(&z_idle_threads[i], z_idle_stacks[i]); + init_idle_thread(i); _kernel.cpus[i].idle_thread = &z_idle_threads[i]; _kernel.cpus[i].id = i; _kernel.cpus[i].irq_stack =