Re: POSIX message queues should not allocate memory on send
From: Martijn Sipkema
Date: Fri May 14 2004 - 05:13:25 EST
> On Fri, May 14, 2004 at 11:30:53AM +0100, Martijn Sipkema wrote:
> > The default mq_msgsize also seems a little large to me, but
> > I don't see why defaults are needed; if I understand the standard
> > correctly then creating a new message queue without mq_attr
> > should create an empty queue, which thus cannot be used to
> > pass messages.
> No idea where you found this.
> "If attr is NULL, the message queue shall be created with
> implementation-defined default message queue attributes."
> Empty queue means a message queue which has no messages in it, not
> that mq_msgsize and/or mq_maxmsg is 0.
> And mq_open with mq_msgsize 0 and/or mq_maxmsg 0 must fail (with EINVAL),
> so the implementation-defined defaults IMHO must be > 0 for both
> " The mq_open() function shall fail if:"
> " [EINVAL]
> O_CREAT was specified in oflag, the value of attr is not
> and either mq_maxmsg or mq_msgsize was less than or equal to zero."
You are correct; defaults are indeed needed. The current default value
for mq_msgsize seems rather large considering that mq_msgsize*mq_maxmsg
bytes will have to be allocated on queue creation. If variable sized large
payload messages are needed one might consider using shared memory in
combination with a message queue.
My main point was that mq_send()/mq_timedsend() may not return ENOMEM
and I am positive I did not misread the standard on that.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/