Limits of vTaskDelay timeout and cancellation behavior in FreeRTOS
0 reputation · 06 Nov 2024, 13:06 UTC
vTaskDelay timeout handling
FreeRTOS v10.x exposes vTaskDelay() as a documented tick‑based timeout primitive. The API suspends the calling task for a fixed number of tick units, but it does not provide a direct cancel‑stop operation. When a higher‑priority task unblocks the delayed task via a notification, the delay is aborted immediately; however, the underlying tick count continues to advance, potentially leading to unexpected re‑entries if the task is resumed before the original timeout expires.
Unresolved kernel behavior
The kernel’s handling of a delayed task that is deleted or suspended is not explicitly documented. Current behavior simply leaves the task in the delayed state, which may cause missed wake‑ups or duplicate activations when the task is later resumed or recreated. Additionally, the effect of changing configTICK_RATE_HZ at runtime on already pending delays is unclear.
Specific questions for investigation
- Does FreeRTOS automatically clear any remaining delay when a task is deleted during a
vTaskDelay()? - If a delayed task is suspended, will the original timeout resume from where it left off upon re‑suspension?
- How does a runtime change to
configTICK_RATE_HZaffect the timing of a task that is already in a delayed state?