I’ve designed a system which uses the idle task to reset (kick/poke/whatever) the watchdog timer. Effectively this means that if the system is stuck in a tight loop for an extended period of time, it will reboot.
Unfortunately, sometimes there are long-running tasks which need to be handled, but the watchdog still needs to be dealt with too. Without yielding some time to the WDT, these long-running tasks will cause spurious watchdog resets. So as an extension to this design, the idle task gives a semaphore after the WDT is reset, which can then be taken by long-running tasks.
This raises the question: what can I do if I have two long-running tasks which want to yield? One watchdog reset is as good as any other, and if I have two tasks waiting, I should be able to wake both of them up. Is it possible to have a semaphore wake two tasks?
One solution I thought of was to have a queue which tracked the task handles of the tasks waiting for the watchdog to update.
When a task wants to wait, it puts its handle in the queue, then calls vTaskSuspend().
When the idle task has finished updating the watchdog, it looks in the queue and calls vTaskResume against all the task handles in the queue.
But this seems a little over-engineered. Can anyone suggest a better way to do this?