Results 1 to 2 of 2
Hi All,
Following function obtains the system-maintained structure for a message queue:
Code:
bool getMessageQueueStats(int mqId, struct msqid_ds* buf)
{
if(msgctl(mqId, IPC_STAT, buf) == -1)
{
return false;
}
return ...
- 06-04-2010 #1Just Joined!
- Join Date
- Nov 2009
- Posts
- 43
theoretical limit on message queue sizes
Hi All,
Following function obtains the system-maintained structure for a message queue:
And following function simply resizes a message queue to a user-defined value, namely, "size":Code:bool getMessageQueueStats(int mqId, struct msqid_ds* buf) { if(msgctl(mqId, IPC_STAT, buf) == -1) { return false; } return true; }
My question is if there is a theoretical limit on user-defined message queue sizes.Code:bool resizeMessageQueue(int mqId, struct msqid_ds* buf, int size) { /* Modify the message queue features */ buf->msg_perm.uid = geteuid(); buf->msg_perm.gid = getegid(); buf->msg_perm.mode = 0660; buf->msg_qbytes = size; // The new size for the message queue if(msgctl(mqId, IPC_SET, buf) == -1) { return false; } return true; }
To put in other words, is it possible to increase the default message queue size to any user-defined value as long as that certain value does not exceed the size of system's physical memory ?
By the way, I use 64-bit Ubuntu 9.04.
Thanks.
- 06-06-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
From the msgctl man page:
Note the last couple of lines. In the header files there is a defined value (probably a #define, but can be a const variable) MSGMNB which is the largest size a user application can set msg_qbytes, unless the application has the CAP_IPC_RESOURCE capability enabled.Code:IPC_SET Write the values of some members of the msqid_ds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msg_ctime member. The following members of the struc- ture are updated: msg_qbytes, msg_perm.uid, msg_perm.gid, and (the least significant 9 bits of) msg_perm.mode. The effective UID of the calling process must match the owner (msg_perm.uid) or creator (msg_perm.cuid) of the message queue, or the caller must be privileged. Appropriate privi- lege (Linux: the CAP_IPC_RESOURCE capability) is required to raise the msg_qbytes value beyond the system parameter MSGMNB.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote