-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CMSIS RTOSv2 API: thread interruption/cancellation #68
Comments
since the new documentation did not mention thread interruption for osThreadAbortWait(), see #83 for an updated suggestion. |
Resolved as suggested in #83. |
since |
Is this problem resolved in the meantime? I.e. in favor of #69? Or do we need to discuss another aspect of thread handling here? |
I'm not sure, both #69 and #83 deal with slightly different issues. A quick look at the values returned by some blocking functions did not reveal an equivalent of POSIX EINTR, i.e. a blocking function was forced to terminate. A waiting thread can be resumed with To interrupt a thread, a separate flag should be set before For a uniform and convenient usage, in CMSIS++ I preferred to add this flag to the thread together with the functions to set/reset/check it. |
@ilg-ul I am a bit confused. You have written about May I ask you to clarify or update this issue referring to the latest RTOS2-API, please? Thank you. |
I did not yet see the full documentation pages for these functions, so my understanding of these functions might not be accurate, but I wanted to share my experience with CMSIS++.
As already mentioned in #67, the two mandatory scheduler functions are suspend() and resume(), which apparently map properly to
osThreadSuspend()
andosThreadResume()
.As for the
osThreadAbortWait()
, I'm not sure what it was intended for. If it was intended to resume a thread suspended while waiting for an event,osThreadResume()
should do the job.If it was intended to provide a method to interrupt a running thread, then, based on the experience with implementing the CMSIS++ portable synchronisation objects, things are a bit more complicated.
The API used by CMSIS++ for this purpose involves two functions:
Each thread has a boolean flag to store the interrupted state. The first function returns this flag. The second function sets/resets this flag.
In addition, the
interrupt(bool)
function will also resume the thread, if the flag is true.Now the whole trick is how to use this flag to break some waits.
For example, here is the semaphore::timed_wait() implementation:
As it can be seen, the interrupted() condition is checked immediately after the thread is resumed, and, if detected, the standard POSIX EINTR error is returned. This pattern should is applied to all waiting loops.
Suggestion:
osThreadAbortWait()
is supposed to do; if it is supposed to handle interruptions, consider the more elaborate mechanism used by CMSIS++The text was updated successfully, but these errors were encountered: