-
Notifications
You must be signed in to change notification settings - Fork 3k
[RTOS] Fixed osThreadGetState() #1731
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
Conversation
Fixed regression that caused terminated threads to return an erroneous state value instead of "inactive".
@@ -905,7 +905,7 @@ uint8_t osThreadGetState (osThreadId thread_id) { | |||
if (__exceptional_mode()) return osErrorISR; // Not allowed in ISR | |||
|
|||
ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer | |||
if (ptcb == NULL) return osErrorParameter; | |||
if (ptcb == NULL) return INACTIVE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this correct? Why this function returns either osValue or state which is different declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, this function should only be returning the state definitions in rt_Task.h, and per the documentation in Thread.h, INACTIVE
is the expected state for threads that have been terminated or otherwise don't exist. However, since there's no state definition for the ISR error I left that line alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note - In the new upcoming cmsis 5 , they declare osThreadState osThreadGetState (osThreadId thread_id);
. I could not locate this function in the current cmsis repository (the version we are using here), thus this was an extension we provided.
When was this regression introduced? Can you point to the commit? |
I backported it from cortex-a implementation as I found it useful. That was before we exposed (rt_tid2ptcb). I propose to remote the check Thanks @neilt6 for pushing this upstream |
👍 |
1 similar comment
👍 |
I merged it, to fix the regression. We should look at it further, as my comment above indicates. I'll create an issue |
Fixed regression that caused terminated threads to return an erroneous state value instead of "inactive".