#1113·FreeRTOS

[Feature Request] Interruptible Blocking Statements

Author: moefear85Created Nov 10, 2023Updated Dec 13, 2023
Labelsenhancement

Is your feature request related to a problem? Please describe. Often I need a thread to block indefinitely on some operation, such as reading from a Queue, but still need to interrupt it when some specific event/scenario occurs, such as closing of resources. Currently such operations can only be unblocked by the queue itself or by a timeout, but not by other tasks bzw external events. This means one is forced to choose an arbitrary timeout period and check for a flag, and such a period is often either too small or too big or together and inefficient.

Describe the solution you'd like An extra function such as xQueueUnblock(QueueHandle_t) that unblocks any thread waiting to recieve or send from/to the queue, but with a failure return value (or convert the return type into an enum on which the user can place a switch statement to determine which case, whether success, failure, interrupted, etc). It can be extended to all timeout based blocking operations in FreeRTOS.

Describe alternatives you've considered The only way to effectively achieve the same, would be to add a dummy Queue (of size 1) used solely for the sake of interrupting, and then having the thread that wants to send/receive, to block on the set of Queues, one being the dummy, the other being the real Queue, such that an interrupting thread would place a dummy value (or read a dummy value) to unblock the target thread and use a separate flag variable to signal what happened. This is unnecessarily complicated and clutters up the code.

How many devices will this feature impact? For me it affects only a few personal projects, but I'm sure it would benefit alot of other people, hobbyists and professionals alike, low and high volume productions.

What are your project timelines? No timeline.

Additional context None available

If you have the same (or similar) feature request, please upvote this issue with thumbs up and use the comments section to provide answers to the questions above.