Back in 2005/2006 there was some discussion about being able to block on multiple queues. An example was given of a task waiting on two serial port queues and using a queue ID in the structure to determine the source. This works well enough for queues of a similar type, but starts to break down when you have queues of differing types. It also makes for less generic (and therefore easily reusable) code.
What I’d really like to see is an extension to xQueueReceive(), which I’ll call xQueueReceiveMultiple(). What I envision as an interface would be passing an array of xQueueHandles, the number of elements in the array, and a timeout value. The return value would be the index of the queue handle which has data ready, or a value to indicate a timeout.
My main application for this comes from user interfaces, where the main control task is waiting for timers to expire (the timers are implemented as a task, where a number of timers can be created without regard to their timeout value, and they’ll fire in order. The RTC is used so the timer task can block), keyboard characters to be pressed, and serial or USB data to arrive.
It’s certainly possible to implement this by polling the various queues, but it lacks two important things: The first is power management. Since all my I/O is interrupt driven, I can put the processor into a low power mode. The second (and arguably more important) is elegance. It just ain’t there.
You mentioned recently about some nifty new improvements to FreeRTOS. Any chance that support for blocking on multiple queues would be one of them?