Type |
Field |
Description |
struct ipc perm |
q perm |
kern ipc perm data structure |
long |
q stime |
Time of last msgsnd( ) |
long |
q rtime |
Time of last msgrcv( ) |
long |
q ctime |
Last change time |
unsigned long |
q qcbytes |
Number of bytes in queue |
unsigned long |
q qnum |
Number of messages in queue |
unsigned long |
q qbytes |
Maximum number of bytes in queue |
int |
q lspid |
PID of last msgsnd( ) |
int |
q lrpid |
PID of last msgrcv( ) |
struct list head |
q messages |
List of messages in queue |
struct list head |
q receivers |
List of processes receiving messages |
struct list head |
q senders |
List of processes sending messages |
The most important field is q_messages, which represents the head (i.e., the first dummy element) of a doubly linked circular list containing all messages currently in the queue.
Each message is broken in one or more pages, which are dynamically allocated. The beginning of the first page stores the message header, which is a data structure of type msg_msg; its fields are listed in Table 19-12. The m_list field stores the pointers to the previous and next messages in the queue. The message text starts right after the msg_msg descriptor; if the message is longer than 4,072 bytes (the page size minus the size of the msg_msg descriptor), it continues on another page, whose address is stored in the next field of the msg_msg descriptor. The second page frame starts with a descriptor of type msg_msgseg, which just includes a next pointer storing the address of an optional third page, and so on.
Type |
Field |
Description |
struct list head |
m list |
Pointers for message list |
long |
m type |
Message type |
int |
m ts |
Message text size |
struct msg msgseg * |
next |
Next portion of the message |
When the message queue is full (either the maximum number of messages or the maximum total size has been reached), processes that try to enqueue new messages may be blocked. The q_senders field of the msg_queue data structure is the head of a list that includes the pointers to the descriptors of all blocked sending processes.
Even receiving processes may be blocked when the message queue is empty (or the process specified a type of message not present in the queue). The q_receivers field of the msg_queue data structure is the head of a list of msg_receiver data structures, one for every blocked receiving process. Each of these structures essentially includes a pointer to the process descriptor, a pointer to the msg_msg structure of the message, and the type of the requested message.
Was this article helpful?
Post a comment