All message queues have an attribute associated with them. This is represented by the
mq_attr structure:
struct mq_attr {
long mq_flags;
long mq_maxmsg;
long mq_msgsize;
long mq_curmsgs;
};
The members in the the structure are: flags set for the message queue (
mq_flags), the maximum number of messages in the queue (
mq_maxmsg), the maximum size of each message (
mq_msgsize), and the number of queued messages (
mq_curmsgs).
The overall resource requirements for a particular message queue are given by
mq_maxmsg and
mq_msgsize. These two can be specified when the queue is created by a call to
mq_open(). The constraints are enforced through the lifetime of the queue: an error is returned if a message larger than
mq_msgsize is sent, and if the message queue is already full, as determined by
mq_maxmsg, the call to queue a message will either block or error out.
Although there are two functions,
mq_getattr() and
mq_setattr(), to retrieve and set attributes, resource limits cannot be changed once the queue has been created. In
NetBSD the super user may however control the global resource limits by using few
sysctl(7) variables.