Re: How to detect a thread is aborted and restart it?


Michael Rosen
 

Jun,

 

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.

 

Mike

 

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?

 

Hi Ram,

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.

 

Regards,

Jun

 

 

From: "Pallala, Ramakrishna" <ramakrishna.pallala@...>
Date: Monday, December 11, 2017 at 03:40
To: "Li, Jun R" <jun.r.li@...>, "zephyr-devel@..." <zephyr-devel@...>
Subject: RE: [Zephyr-devel] How to detect a thread is aborted and restart it?

 

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.

 

Thanks,

Ram

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Li, Jun R
Sent: Monday, December 11, 2017 4:49 PM
To: zephyr-devel@...
Subject: [Zephyr-devel] How to detect a thread is aborted and restart it?

 

Hello everyone,

 

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?

 

Thank you!

 

Regards,

Jun Li

 

Join devel@lists.zephyrproject.org to automatically receive all group messages.