# Change the task block time

**URL:** <https://forums.freertos.org/t/change-the-task-block-time/11117>\
**Category:** Kernel\
**Created:** [November 12, 2020, 11:45am UTC](https://forums.freertos.org/t/change-the-task-block-time/11117 "2020-11-12T11:45:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry\_szc](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jerry\_szc](https://forums.freertos.org/u/Jerry_szc)\
**Post date:** [November 12, 2020, 11:45am UTC](https://forums.freertos.org/t/change-the-task-block-time/11117/1 "2020-11-12T11:45:54Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [November 12, 2020, 11:59am UTC](https://forums.freertos.org/t/change-the-task-block-time/11117/2 "2020-11-12T11:59:02Z")

</div>

Sorry - what do you mean exactly ? `xQueueReceive` has a timeout argument…

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [November 12, 2020, 12:36pm UTC](https://forums.freertos.org/t/change-the-task-block-time/11117/3 "2020-11-12T12:36:27Z")

</div>

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().

---

<div class="post-metadata">

**Author:** ![Jerry\_szc](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@Jerry\_szc](https://forums.freertos.org/u/Jerry_szc)\
**Post date:** [November 13, 2020, 12:41am UTC](https://forums.freertos.org/t/change-the-task-block-time/11117/4 "2020-11-13T00:41:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [November 13, 2020, 8:05pm UTC](https://forums.freertos.org/t/change-the-task-block-time/11117/5 "2020-11-13T20:05:39Z")

</div>

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.
