Re: POSIX message queues should not allocate memory on send
From: Martijn Sipkema
Date: Fri May 14 2004 - 06:44:28 EST
> On Fri, May 14, 2004 at 12:09:46PM +0100, Martijn Sipkema wrote:
> > 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
> > 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.
> Even that is not clear.
> " Implementations may support additional errors not included in this
> may generate errors included in this list under circumstances other
> those described here, or may contain extensions or limitations that
> prevent some errors from occurring. The ERRORS section on each
> reference page specifies whether an error shall be returned, or
> it may be returned. Implementations shall not generate a different
> number from the ones described here for error conditions described in
> this volume of IEEE Std 1003.1-2001, but may generate additional
> unless explicitly disallowed for a particular function."
> Explicitely disallowed in the general section is only EINTR for the THR
> option functions unless explitely listed for that function and nothing
> I don't see ENOMEM explicitly forbidden for mq_send/mq_timedsend nor
> any wording in mq_open description which would require the buffers to
> be preallocated.
Indeed maybe returning ENOMEM from mq_send() is conforming to the
standard. Perhaps returning ENOMEM instead of ENOSPC from
mq_open() to indicate that there is unsufficient space for the creation of
a new queue isn't; I'm no longer sure.
What _is_ clear from the standard is that a queue is supposed to be
allocated on creation, even if it may not be required. Why else would
ENOSPC be explicitely listed for mq_open() when creating a new
queue, but not for mq_send()/mq_timedsend()?
What use is a message queue for a realtime application when on
mq_send() it may have to wait for memory allocation that may even
Even if POSIX allows errors to be returned that are not in the function's
ERRORS list, I don't think one should do this if it can be avoided.
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/