Hi!
Let's say I have a few producer tasks and one consumer task that communicate through a mailbox. In most cases I pass small messages so everything is easy.
But in a few cases I also need to pass a larger buffer. The buffer will be filled appropriately by each producer task and then consumed by the consumer task. I think that it is most efficient to just pass a pointer to a single large global buffer to my mailbox (i.e. the buffer is passed by reference to the consumer task).
Now I wonder what is the best way to protect the buffer so that it can be safely shared between the producer tasks and the consumer task. Should I use semaphores? If so where and how many? And do I have to limit the mailbox size to one message to prevent corruption of the buffer?
Thanks for any hints,
Anguel