Results 1 to 3 of 3
Actually I dint understand allocation and freeing of memory in message queue.
The sender with message id sends message and receiver receives
and uses msgctl()-->to free the memory.
Now the ...
- 09-11-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 8
Interview question message queue
Actually I dint understand allocation and freeing of memory in message queue.
The sender with message id sends message and receiver receives
and uses msgctl()-->to free the memory.
Now the quesiotn whct is freeing here ?Is it dynamic?Then it shud have malloc/calloc when allocating?But I dont see any thing here.
Where from the memory is allocated and where it is freed?
Please some one help me thanks in advance
- 09-12-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
Huh? The commands available for msgctl() are IPC_STAT, IPC_SET, IPC_RMID, IPC_INFO, MSG_INFO, and MSG_STAT. The only one that really manipulates kernel memory structurs is IPC_SET. You can change the maximum number of bytes allowed in a queue, but a couple of caveates here. One is that you need to have the appropriate privileges. Two is that if you increase the msg_qbytes field in the msqid_ds structure, it will only take effect when you create a new queue. It doesn't affect current queues as far as I know.
So, you have to manage your own memory as far as local buffers are concerned. The queue code in the kernel handles kernel allocation needs. When you send a message, it is copied by the kernel code into the kernel message structures. When you receive a message, you provide a pointer to a message structure of your own. The kernel code copies the kernel message data received into that buffer.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 09-12-2010 #3Linux 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
You may also want to review the mq_overview man page for more informatioon: man mq_overview
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote