質問

I am dealing with Message Passing IPCS method. I do have few question regarding this:

  1. KEY field in ipcs -q shows me 0x00000000 what does this means ?
  2. Can i see what messsage is passes using msqid ?
  3. If two entries are present (for a particular user) after executing command ipcs -q. Does this means that two messages were passed by this particular user ?
  4. If used-bytes and message fields are set as 0 what does this mean?
  5. Is there away to see if message queue is full or not?
  6. How many queues can we have for one particular user?

I tried goggling, but was not able to find answer to these questions. Please help

役に立ちましたか?

解決

1. The "key" field of the Shared memory segments is usually 0x00000000. This indicates the IPC_PRIVATE key specified during creation of the shared memory segment. The manual of shmget() contains more details.

2. AFAIK, this cannot be done. If any msg is "de-queued" from the msgQ, then the intended receiver will not see it.

3. The 2 entries in the list of message queues indicates that there are currently 2 active message queues on the system identified by their corresponding unique keys.

Creating additional msgQ : ipcmk -Q
Deleting an existing msgQ : ipcrm -Q <unique-key>

4. The used-bytes and messages fields set to 0 indicate that currently no transfers have occurred using that particular msgQ.

5. Currently one way to do this to obtain the number of msgs currently queued-up in the msgQ programmatically as shown in the following C snippet. Next this can be compared with the size of the msgQ as demonstrated in this answer.

int ret = msgctl(msqid, IPC_STAT, &buf);  
uint msg = (uint)(buf.msg_qnum);  
printf("msgs in Q = %u\n", msg);  

6. There exists a limit on the total memory used by all the msgQs on the system combined together. This can be obtained by ulimit -q. The amount of bytes used in a msgQ is listed under the used-bytes column in the output of ipcs -Q. The total number of msgQs is limited only by the amount of memory available to create a new msgQ from the msgQ memory pool limit seen above.

Also checkout the latter part of this answer for a few sample operations on POSIX message queues.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top