The biggest disadvantages of the POSIX message queue are:
- The POSIX message queue does not make it a
select() compatible requirement . (It works with select() on Linux, but not on a Qnx system) - He has surprises.
The Unix Datagram socket performs the same task in the POSIX message queue. And the Unix Datagram socket works in the socket layer. It can be used with select() / poll() or other I / O wait methods. Using select() / poll() has the advantage of developing an event-based system. In this way, a busy cycle can be avoided.
There is a surprise in the message queue. Think about mq_notify() . It is used to receive event-reception. It looks like we can tell something about the message queue. But it actually registers for notification, but notifies nothing.
More surprise about mq_notify() is that it should be called after every mq_receive() , which can cause a race condition (when some other call to the process / thread mq_send() between the call to mq_receive() and mq_notify() >).
And it has a whole set of mq_open, mq_send(), mq_receive() and mq_close() with its own definition, which is redundant and in some cases incompatible with the specification of the socket open(),send(),recv() and close() method.
I do not think the message queue should be used for synchronization. eventfd and signalfd .
But he has some real-time support. It has priority features.
Messages are placed on the queue in decreasing order of priority, with newer messages of the same priority being placed after older messages with the same priority.
But this priority is also available for the socket as out-of-band data!
Finally, for me, the POSIX message queue is an outdated API. I always prefer the Unix Datagram socket over the POSIX message queue.
shuva Jun 08 '17 at 19:27 2017-06-08 19:27
source share