Andna
Andna

Reputation: 6689

POSIX queues and msg_max

I am toying a bit with POSIX queues and I encountered a problem. When creating a new queue I can specify for example the size of the message and how many messages there can be in the queue. My normal limit is 10 as found in

/proc/sys/fs/mqueue/msg_max

is there an easy way to change it during program execution, apart from

echo number > /proc/sys/fs/mqueue/msg_max

maybe some system call for setting such things exists.

Upvotes: 6

Views: 11609

Answers (3)

driverblock
driverblock

Reputation: 51

Finally found this: Re: POSIX Message Queues

Edit /etc/sysctl.conf and add the lines:

# Increase message queue

fs.mqueue.msg_max = 100

Works for me on Raspbian

Upvotes: 4

Duck
Duck

Reputation: 27542

The queue is set when it is created and you can't change it midstream. You can increase the number of queue messages by running as a privileged user at the time you create the queue. So you either have to run a separate program (as a PU) to create the queue or run as a PU, create the queue, and drop the privileges when done. The number of messages you can increase up to is still limited by the overall size of the queue so you have to do some division (minus a small amount of overhead byes). If you Google around there is a simple formula for this.

Upvotes: 2

Michael Slade
Michael Slade

Reputation: 13877

No.

That limit is a system-wide limit; that's why it's in /proc/sys. If you want to change it you will have to use the echo command you have already shown.

Upvotes: 4

Related Questions