I am thinking of using the queuing mechanism described in Blocking On Multiple RTOS Objects (http://www.freertos.org/Pend-on-multiple-rtos-objects.html) to send commands and (optionally) data to a driver. To avoid needing excessive queue memory, data will be passed by reference (pointer). However, the task which posted the command (which owns the data buffer and constructed the data) needs to know when the driver has finished with the data (and hence when it can re-use the buffer).
The solution that sprang to mind is to queue a semaphore handle along with the data pointer. The posting task could block on the semaphore (by trying to ‘take’ it) until the driver has finished with the data and unblocked (‘given’) the semaphore. However, semaphores don’t work like that (they seem to be set up to indicate that something is ‘available’ not ‘busy’), and it is not allowed for a task to ‘give’ a semaphore if it did not originally ‘take’ it.
Any thoughts? I suspect that there is an elegant solution, but I can’t see it…
Thanks in advance, Eddie.