FreeRTOS 中 portMAX_DELAY 实际等待多长时间?
虽然 portMAX_DELAY 被列为无限等待的值,但只有在 FreeRTOS 配置中启用 INCLUDE_vTaskSuspend 时,它才会实际无限等待。
portMAX_DELAY 通常定义为 0xFFFFFFFF 即 2^32-1:
portmax_delay.cpp
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL(但是如果使用 configUSE_16_BIT_TICKS 启用 16 位 tick,它将被定义为 0xFFFF(2^16-1)。
如果启用了 INCLUDE_vTaskSuspend,这被视为特殊值并将实际无限等待。如果未定义 INCLUDE_vTaskSuspend,它将只等待 0xFFFFFFFF 个 tick(假设 32 位系统 tick。
换句话说,如果 FreeRTOS 定义为每毫秒 tick 一次,这将等待仅约 7 周。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow