POSIX queues and msg_max

时光毁灭记忆、已成空白 提交于 2019-12-22 08:18:54

问题


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.


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/10558721/posix-queues-and-msg-max

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!