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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/rtos/rtx/TARGET_CORTEX_A/rt_CMSIS.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.


return ptcb->state;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/rtos/rtx/TARGET_CORTEX_M/rt_CMSIS.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ uint8_t osThreadGetState (osThreadId thread_id) {
if (__get_IPSR() != 0U) return osErrorISR; // Not allowed in ISR

ptcb = rt_tid2ptcb(thread_id); // Get TCB pointer
if (ptcb == NULL) return osErrorParameter;
if (ptcb == NULL) return INACTIVE;

return ptcb->state;
}
Expand Down