I start a thread in zephyr like this:
K_THREAD_DEFINE(my_name, STACKSIZE, my_func, NULL, NULL,
NULL, PRIORITY, 0, 0);
but it does crash after some time. How do I check it's status to restart it when it crashed?
I start a thread in zephyr like this:
K_THREAD_DEFINE(my_name, STACKSIZE, my_func, NULL, NULL,
NULL, PRIORITY, 0, 0);
but it does crash after some time. How do I check it's status to restart it when it crashed?
The uart shell has a command that prints all threads running. It is registered as the function cmd_kernel_threads
(at zephyr\subsys\shell\modules\kernel_service.c:144
for my version). Starting from there you should find your info.
static int cmd_kernel_threads(const struct shell *shell,
size_t argc, char **argv)
{
ARG_UNUSED(argc);
ARG_UNUSED(argv);
shell_print(shell, "Scheduler: %u since last call", sys_clock_elapsed());
shell_print(shell, "Threads:");
k_thread_foreach(shell_tdata_dump, (void *)shell);
return 0;
}
I could be wrong but I believe you wont be able to access the thread chained list (_kernel.threads
in thread.c
). There should be a better way but you can write a callback to give to k_thread_foreach
instead of shell_tdata_dump
. In this callback you'd look sequentially for a thread named as yours.