The thread becomes ready regardless of the reason why the thread was blocked.
Actual Behavior
The thread is still in BLOCKED state after calling osThreadResume() when thread was not blocked by osThreadSuspend().
Reason
osThreadResume() calls vTaskResume(), which checks prvTaskIsTaskSuspended().
prvTaskIsTaskSuspended()only returns true when the thread was suspended using osThreadSuspend().
From FreeRTOS - tasks.c:1836
/* Is it in the suspended list because it is in the Suspended
state, or because is is blocked with no timeout? */
if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE )
Solution
The FreeRTOS function xTaskAbortDelay() must be used instead so that the implementation is correct according to the documentation linked above.
FreeRTOS Kernel 10.4.3 LTS Patch 3 CMSIS-FreeRTOS v 10.5.1
Expected Behavior
The function should unblock any thread, regardless of why the thread was blocked.
The documentation of osThreadResume states that
Actual Behavior
The thread is still in
BLOCKED
state after callingosThreadResume()
when thread was not blocked byosThreadSuspend()
.Reason
osThreadResume()
callsvTaskResume()
, which checksprvTaskIsTaskSuspended()
.prvTaskIsTaskSuspended()
only returns true when the thread was suspended usingosThreadSuspend()
.From FreeRTOS -
tasks.c:1836
Solution
The FreeRTOS function
xTaskAbortDelay()
must be used instead so that the implementation is correct according to the documentation linked above.