I am designing a single-process multi-threaded embedded Linux application. The design includes client-server subsystem where a worker thread receives messages posted by other threads on a POSIX message queue.
I need the queue to exhibit non-blocking send and blocking receive semantics. I can think of several ways to achieve the above: - Creating two separate message queue descriptions for accessing the queue for the sake of send and receive, that is calling mq_open twice. This will be followed by setting the O_NONBLOCK flag of the description that will be used for sending via the queue.
Specifying blocking behavior and using mq_timedsend in lieu of mq_send
Specifying blocking behavior and calling mq_getattr before mq_send to avoid blocking on send
The first solution is probably the preferred one, however for this to work it must be guaranteed that each call to mq_open creates a new message queue description object (I am also assuming that threads in a process can use multiple such objects to perform operation on the same queue).
POSIX seems to provide such a guarantee (https://pubs.opengroup.org/onlinepubs/009695399/functions/mq_open.html) however Linux documentation does not explicitly say that each call to mq_open creates a new message queue description object.
Is there such a guarantee for Linux?
Thanks,