diff --git a/doc/guides/debug_tools/thread-analyzer.rst b/doc/guides/debug_tools/thread-analyzer.rst index 39fd8bd9c9d..ca5ae6f6e49 100644 --- a/doc/guides/debug_tools/thread-analyzer.rst +++ b/doc/guides/debug_tools/thread-analyzer.rst @@ -31,7 +31,7 @@ information from Thread Analyzer:: thread_b : STACK: unused 740 usage 284 / 1024 (27 %); CPU: 0 % thread_analyzer : STACK: unused 8 usage 504 / 512 (98 %); CPU: 0 % thread_a : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 98 % - idle 00 : STACK: unused 204 usage 116 / 320 (36 %); CPU: 0 % + idle : STACK: unused 204 usage 116 / 320 (36 %); CPU: 0 % thread_b: Hello World from cpu 0 on qemu_x86! thread_a: Hello World from cpu 0 on qemu_x86! thread_b: Hello World from cpu 0 on qemu_x86! @@ -44,7 +44,7 @@ information from Thread Analyzer:: thread_b : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 7 % thread_analyzer : STACK: unused 8 usage 504 / 512 (98 %); CPU: 0 % thread_a : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 9 % - idle 00 : STACK: unused 204 usage 116 / 320 (36 %); CPU: 82 % + idle : STACK: unused 204 usage 116 / 320 (36 %); CPU: 82 % thread_b: Hello World from cpu 0 on qemu_x86! thread_a: Hello World from cpu 0 on qemu_x86! thread_b: Hello World from cpu 0 on qemu_x86! @@ -57,7 +57,7 @@ information from Thread Analyzer:: thread_b : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 7 % thread_analyzer : STACK: unused 8 usage 504 / 512 (98 %); CPU: 0 % thread_a : STACK: unused 648 usage 376 / 1024 (36 %); CPU: 8 % - idle 00 : STACK: unused 204 usage 116 / 320 (36 %); CPU: 83 % + idle : STACK: unused 204 usage 116 / 320 (36 %); CPU: 83 % thread_b: Hello World from cpu 0 on qemu_x86! thread_a: Hello World from cpu 0 on qemu_x86! thread_b: Hello World from cpu 0 on qemu_x86! diff --git a/kernel/init.c b/kernel/init.c index cd381614aff..1fccdd12be3 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -262,9 +262,14 @@ static void init_idle_thread(int i) k_thread_stack_t *stack = z_idle_stacks[i]; #ifdef CONFIG_THREAD_NAME - char tname[8]; +#if CONFIG_MP_NUM_CPUS > 1 + char tname[8]; snprintk(tname, 8, "idle %02d", i); +#else + char *tname = "idle"; +#endif + #else char *tname = NULL; #endif /* CONFIG_THREAD_NAME */ diff --git a/subsys/testsuite/ztest/src/ztress.c b/subsys/testsuite/ztest/src/ztress.c index 4ee04f6fd0a..f74764f077a 100644 --- a/subsys/testsuite/ztest/src/ztress.c +++ b/subsys/testsuite/ztest/src/ztress.c @@ -265,7 +265,7 @@ static void ztress_thread(void *data, void *prio, void *unused) static void thread_cb(const struct k_thread *cthread, void *user_data) { #define GET_IDLE_TID(i, tid) do {\ - if (strcmp(tname, "idle 0" STRINGIFY(i)) == 0) { \ + if (strcmp(tname, (CONFIG_MP_NUM_CPUS == 1) ? "idle" : "idle 0" STRINGIFY(i)) == 0) { \ idle_tid[i] = tid; \ } \ } while (0)