|
Message queues provide an asynchronous way for processes to pass messages. After a message queue is established by calling msgget(), sending processes and receiving processes can exchange messages via the message queue. The sending process sends the messages to the specified message queue, and the receiver tries to get the messages from the specified message queue. If no message is available on the message queue, the receiver is blocked or returns with some flag, depending on whether it is willing to wait. Table 13-2 provides brief descriptions of the three kernel parameters for message queues present in the current Linux 2.4/2.6 implementation.
Note that the maximum value listed in the fourth column is a value based on the data type. The three kernel parameters are of type int, so on a 3-bit Intel machine, the hard limit is 2GB. Linux also defines other message queue-related parameters that are not currently in use. The following sections examine message queue-related parameters in detail. msgmnimsgmni defines a system-wide message queue limit. As with semaphores, message queues have an associated identifier. At system initialization time, the kernel creates an array of pointers that point to the message queue identifier structures. The number of entries in that array is determined by msgmni. For each message queue, the Linux kernel allocates 44 bytes for the identifier and 96 bytes for the message queue structure. You can dynamically increase msgmni to get more message queue resources. As with semaphores, the maximum number of message queue identifiers is limited by IPCMNI. The default limit is 16, which is probably not enough to get some of the big database applications running smoothly. We recommend the default limit be set as high as 128 if you know your system will run a database application. msgmaxmsgmax restricts the size of a message that a process can send. The msgsnd() function enforces this limit. If the message to be sent exceeds this limit, an error is returned. This parameter can be tuned at runtime. msgmnbmsgmnb determines the capacity of a message queue. The value of msgmnb is saved in one field of the message queue identifier structure and is used to determine whether there is space to enqueue a new message. The default value is 16384. The value can be modified dynamically. Modifying the value of msgmnb affects the capacities of all new message queues. The msgctl() system call allows the user to increase the capacity of an existing message queue. Unused Message Queue ParametersFive additional message queue-related parameters are predefined in Linux but are not yet used:
|
|