Skip to content

Commit ecf2cb5

Browse files
Maxim Adelmannashif
authored andcommitted
kernel shell, stacks shell commands: iterate unlocked on SMP
call k_thread_foreach_unlocked to avoid assertions caused by calling shell_print while holding a global lock Signed-off-by: Maxim Adelman <[email protected]>
1 parent fbb6cd1 commit ecf2cb5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

subsys/shell/modules/kernel_service.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ static int cmd_kernel_threads(const struct shell *sh,
164164

165165
shell_print(sh, "Scheduler: %u since last call", sys_clock_elapsed());
166166
shell_print(sh, "Threads:");
167+
168+
#ifdef CONFIG_SMP
169+
k_thread_foreach_unlocked(shell_tdata_dump, (void *)sh);
170+
#else
167171
k_thread_foreach(shell_tdata_dump, (void *)sh);
172+
#endif
168173
return 0;
169174
}
170175

@@ -208,7 +213,11 @@ static int cmd_kernel_stacks(const struct shell *sh,
208213

209214
memset(pad, ' ', MAX((THREAD_MAX_NAM_LEN - strlen("IRQ 00")), 1));
210215

216+
#ifdef CONFIG_SMP
217+
k_thread_foreach_unlocked(shell_stack_dump, (void *)sh);
218+
#else
211219
k_thread_foreach(shell_stack_dump, (void *)sh);
220+
#endif
212221

213222
/* Placeholder logic for interrupt stack until we have better
214223
* kernel support, including dumping arch-specific exception-related

0 commit comments

Comments
 (0)