ARM-software/CMSIS-FreeRTOS

osThreadResume does not resume blocked thread

futurezeb opened this issue · 1 comments

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

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.

Hi,

many thanks for a nice explanation and proposed solution! The fix for this problem was now finally implemented and pushed into main repo branch.