Current the freeRTOS task can’t support to modify block time for waiting a queue. I checked the TCB structure, it seems the ECB memeber that the listitem “xStateListItem” and “xEventListItem” maybe can support it. Is anyone add this kind of API to support to modify the blocktime? I need your help!
Sorry - what do you mean exactly ?
xQueueReceive has a timeout argument…
One big issue is that FreeRTOS doesn’t store what the Block Time was, it only computes the wakeup time and schedules the task to be woken at that time if the Queue (or whatever) doesn’t wake it up before then.
I will say that I can’t think of any real situation where I would want to change the block time for a block that is currently in processes, except to terminate the block, which you can do with xTaskAbortDelay().
Thanks your information! I explain more detailed. A task will get more message during the normal mode,so it must be wakeup in short period to process key detecting, period maybe 100ms. When system enter sleep mode, the task just monitor a device only,the wakeup preriod is 1000ms,it can save power. The TCB can’t store the blocktime,so I can’t find a API to implement the dynamic to modify the blocktime.
Sounds like perhaps not doing things the right way. I would expect a task that is waiting on a queue for messages to not be the task to process key detection. This is perhaps a case for using a timer to run a timer callback to either do the key detection itself, or trigger a task to do the key detection. Then the timer could be reprogrammed for its period.
Even better would be if the key presses could generate an interrupt, but that doesn’t work on all systems.
Now on option if the task waiting on the queue does need to do the keyboard scan would be for that timer callback to just post an appropriate message onto the queue to make it do the button scan.