Re: How to detect a thread is aborted and restart it?
I don’t see much other way unfortunately; I think it would be nice is Zephyr added Fault hooks per thread so you could set a function to be called on a thread faulting.
Otherwise, you can always add kernel/include to the include search path for your project so you don’t have to move anything via:
subdir-cc-flags-y += -I$(ZEPHYR_BASE)/kernel/include
Not ideal, but should give you access to these functions.
From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Li, Jun R
Sent: Monday, December 11, 2017 3:10 PM
To: Pallala, Ramakrishna <ramakrishna.pallala@...>; zephyr-devel@...
Subject: Re: [Zephyr-devel] How to detect a thread is aborted and restart it?
Thanks for providing this helpful information! However, the two functions seem not to be published API functions and can’t be included without being moved to somewhere. Also, unfortunately, I can’t find a public function in zephyr/include which can do the same thing as these two internal functions.
From: "Pallala, Ramakrishna" <ramakrishna.pallala@...>
Hi Jun Li,
There are few inline functions in kernel/include/ksched.h from which you can get the status of a particular thread.
static inline int _is_thread_prevented_from_running(struct k_thread *thread)
static inline int _is_thread_state_set(struct k_thread *thread, u32_t state)
From the above functions you can get the status of your critical thread and based the status you can invoke/restart the thread from background thread.
My application has one critical thread which needs to be always running. However, sometimes, it could crash due to some incorrect memory operations. I want to find a way to detect the thread abortion event and restart that thread from a background thread. Is there a way in Zephyr to check the current status of a specific thread and restart it if it aborts?