Skip to content

[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

Merged
merged 1 commit into from
May 23, 2016
Merged

[RTOS] Fixed osThreadGetState() #1731

merged 1 commit into from
May 23, 2016

Conversation

neilt6
Copy link
Contributor

@neilt6 neilt6 commented May 11, 2016

Fixed regression that caused terminated threads to return an erroneous state value instead of "inactive".

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@0xc0170
Copy link
Contributor

0xc0170 commented May 13, 2016

Fixed regression that caused terminated threads to return an erroneous state value instead of "inactive".

When was this regression introduced? Can you point to the commit?

@neilt6
Copy link
Contributor Author

neilt6 commented May 13, 2016

@0xc0170 The regression was introduced with 9a68561. I noticed it when one of my programs quit working because it could no longer determine when threads had been terminated.

@0xc0170
Copy link
Contributor

0xc0170 commented May 13, 2016

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 if (__get_IPSR() != 0U) return osErrorISR;, that does not make sense there (other thread functions within the file do not check it neither).
Or it might be cleaner just use tcb in the Thread.cpp as we used to and remove this extension from kernel (keep our changes to minimal).

Thanks @neilt6 for pushing this upstream

cc @TomoYamanaka

@sg-
Copy link
Contributor

sg- commented May 21, 2016

👍

1 similar comment
@TomoYamanaka
Copy link
Contributor

👍

@0xc0170 0xc0170 merged commit a2bfca7 into ARMmbed:master May 23, 2016
@0xc0170
Copy link
Contributor

0xc0170 commented May 23, 2016

I merged it, to fix the regression. We should look at it further, as my comment above indicates. I'll create an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants