ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have developed an application on Fedora 14 in C++. I need POSIX message queues for IPC. I need multiple message queues. I create a message queue as below:
From a non-root user, the application can only create 9 message queues. On creation of the 10th message queue, mq_open() generates error ENOMEM. No other application can create a new queue as long as 9 queues are open.
From a root user, the application can create more than 9 queues.
This should list how many bytes can be allocated towards the creation of message queues. If the number is too small for your needs, you can try to increase it using a similar command, but in this case, specifying the desired size:
Code:
ulimit -q <size>
You also may have better success if you specify the (max) size of the data object you plan to send through your queues. You can do this by specifying the attributes for the queue; for example:
The process max POSIX queue data size is 819200 bytes. Since I used default attributes in mq_open(), the queue was created with space for 10 messages each message of 8192 bytes. This way, for 10 queues the size limit of 819200 bytes would be reached. So the application was able to create only 9 queues.
I added below lines in /etc/security/limits.conf:
Code:
* hard msgqueue 8192000
* soft msgqueue 8192000
Before launching the application I do:
Code:
ulimit -q 8192000
This time I do not get "Operation not permitted" error. I launch the application and it can create more than 9 queues!
Thank you for your suggestions. I really appreciate it.
Does your application really need to send messages that are 8192 bytes in size? If you know that your messages will be smaller, then you should specify that size and the max number of messages that can be queued, as I demonstrated earlier.
Otherwise, as you found out, the message queue is created with the default message size (8192 bytes) and a depth of 10 messages.
A message can be maximum 2048 bytes in size. So changing the message size and reducing the number of messages in the queue will help in creating more message queues. I will create the messages queues with attributes as you have pointed.
Thank you for your kind support. It was really helpful.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.