Understanding Queues
Posted: Tue Oct 25, 2016 9:16 pm
Hi all,
I have an application with an architecture similar to the Actor model (Wiki link) where a queue of fixed-length buffers ("messages") is processed one at a time by a worker thread. I am trying to understand the best way to do this in ChibiOS (specifically NIL, although I'd consider RT if there were RT-only features that would be very helpful). I am working on the most recent SVN trunk.
I can see a way to do this using a message pool and mailboxes, by calling chPoolAlloc from the thread sending the message and posting the resulting void * to a mailbox which the worker thread pends on, then calling chPoolFree from the worker thread when processing is complete. This seems pretty complicated but would certainly work. However, I also notice a couple other data structures that could be useful. There are queue implementations, formerly in RT but now only in HAL. Are these more appropriate for what I'm trying to do? What about the synchronous message interface? It seems like there are a lot of options but a lack of guidance on their intended use cases.
Appreciate the help!
I have an application with an architecture similar to the Actor model (Wiki link) where a queue of fixed-length buffers ("messages") is processed one at a time by a worker thread. I am trying to understand the best way to do this in ChibiOS (specifically NIL, although I'd consider RT if there were RT-only features that would be very helpful). I am working on the most recent SVN trunk.
I can see a way to do this using a message pool and mailboxes, by calling chPoolAlloc from the thread sending the message and posting the resulting void * to a mailbox which the worker thread pends on, then calling chPoolFree from the worker thread when processing is complete. This seems pretty complicated but would certainly work. However, I also notice a couple other data structures that could be useful. There are queue implementations, formerly in RT but now only in HAL. Are these more appropriate for what I'm trying to do? What about the synchronous message interface? It seems like there are a lot of options but a lack of guidance on their intended use cases.
Appreciate the help!