ARM-software / CMSIS-FreeRTOS

FreeRTOS adaptation for CMSIS-RTOS Version 2
https://arm-software.github.io/CMSIS-FreeRTOS/
Other
528 stars 141 forks source link

osThreadResume does not resume blocked thread #69

Closed futurezeb closed 1 year ago

futurezeb commented 1 year ago

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.

VladimirUmek commented 1 year ago

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.