-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
K_ESSENTIAL option doesn't have any effect on k_create_thread #45545
Comments
I originally assumed this got dropped in the rework of thread abort that happened about a year ago. But here's the commit that removes the old implementation, and it's not present there either (it's just an assert): c0c8cb0 So I guess we've never done this right per the docs. Oops. Should be a simple fix. |
So if I understand correctly, this option was dropped? Is there a similar facility in the kernel that we could use? |
No, we just never did it the way we documented it. I don't see why we shouldn't match the docs, your use of K_ESSENTIAL as a kind of watchdog feature seems very reasonable to me, and the added code is literally as simple as |
Oh I see. Happy to test a patch if you send it my way :D |
Is there any work going to be done around this? |
@andyross could you please open a Pull Request with the fix? |
Documentation specifies that aborting/terminating/exiting essential threads is a system panic condition, but we didn't actually implement that and allowed it as for other threads. At least one app wants to exploit this documented behavior as a "watchdog" kind of condition, and that seems reasonable. Do what we say we're supposed to do. This also includes a small fix to a test, which seemed like it was written to exercise exactly this condition. Except that it failed to detect whether or not a system fatal error was actually signaled and was (incorrectly) indicating "success". Check that we actually enter the handler. Fixes zephyrproject-rtos#45545 Signed-off-by: Andy Ross <[email protected]>
Fix up. Just to quibble with priority though: this is a silly thing to mark "high". The obvious workaround to a lack of system panic on exiting essential threads is just to panic at the end of the thread function. :) Or if you want to catch async aborts, join a thread to it and panic in that. |
Documentation specifies that aborting/terminating/exiting essential threads is a system panic condition, but we didn't actually implement that and allowed it as for other threads. At least one app wants to exploit this documented behavior as a "watchdog" kind of condition, and that seems reasonable. Do what we say we're supposed to do. This also includes a small fix to a test, which seemed like it was written to exercise exactly this condition. Except that it failed to detect whether or not a system fatal error was actually signaled and was (incorrectly) indicating "success". Check that we actually enter the handler. Fixes #45545 Signed-off-by: Andy Ross <[email protected]>
Documentation specifies that aborting/terminating/exiting essential threads is a system panic condition, but we didn't actually implement that and allowed it as for other threads. At least one app wants to exploit this documented behavior as a "watchdog" kind of condition, and that seems reasonable. Do what we say we're supposed to do. This also includes a small fix to a test, which seemed like it was written to exercise exactly this condition. Except that it failed to detect whether or not a system fatal error was actually signaled and was (incorrectly) indicating "success". Check that we actually enter the handler. Fixes zephyrproject-rtos#45545 Signed-off-by: Andy Ross <[email protected]>
Describe the bug
In our application we spawn a thread at innit that will be running a loop during all the lifecycle of the app. If that thread stops execution or exits for any reason we want the whole system to restart. To achieve this we configure the thread with the option K_ESSENTIAL which according to the documentation:
This option tags the thread as an essential thread. This instructs the kernel to treat the termination or aborting of the thread as a fatal system error.
What we observe is that configuring the K_ESSENTIAL option has no effect whatsoever and that if the thread stops the rest of the app keeps running.
To Reproduce
Here a simple app to reproduce the problem:
Expected behavior
When the spawned thread exits the app should be restarted (or halted depending on the platform)
Impact
This is a good fit for our application since the devices that are running it are spread geographically and adds robustness to the design.
Environment (please complete the following information):
We have observed this behavior when testing on qemu_cortex as well as on our hardware board which is a Nordic Semiconductors nrf9160 based one.
We are using Nordic SDK 1.9.1 which ships with Zephyr OS v2.7.99
The text was updated successfully, but these errors were encountered: