Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 780
Andna Avatar asked May 11 '12 21:05

Andna


3 Answers

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.

like image 105
Michael Slade Avatar answered Sep 27 '22 17:09

Michael Slade


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.

like image 21
Duck Avatar answered Sep 27 '22 17:09

Duck


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

like image 36
driverblock Avatar answered Sep 27 '22 19:09

driverblock