Message Queue Parameters

team bbl


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.

Table 13-2. Kernel Parameters Associated with Message Queues

Name

Description

Default

Maximum

msgmni

Maximum of message queues

16

2GB

msgmax

Maximum message size in bytes

8192

2GB

msgmnb

Maximum bytes on a message queue

16384

2GB


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.

msgmni

msgmni 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.

msgmax

msgmax 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.

msgmnb

msgmnb 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 Parameters

Five additional message queue-related parameters are predefined in Linux but are not yet used:

  • msgpool. The maximum size of the message pool in kilobytes. The default value is set to msgmni*msgmnb/1024.

  • msgtql. The maximum count of system-wide message headers. The Linux kernel constructs a message by attaching a message header with the message body, which is obtained from the sending process, and then stores it in the corresponding message queue. Basically, this reflects the total number of messages a system allows. Currently, in the 2.4/2.6 kernel, this parameter is defined with a default value of msgmnb, but the Linux 2.6 kernel does not check this limit when a new message needs to be sent.

  • msgmap. Defines the number of entries in a message queue map and is similar to the semmap parameter for semaphores. The IPC facility of other UNIX-like operating systems uses a resource allocation map to provide a convenient way of managing a small piece of kernel memory in case the resource is frequently allocated and released. This is not the method currently implemented in the Linux kernel, but the Linux kernel reserves this parameter for possible use in the future. The default value of msgmap is msgmni (16).

  • msgssz. The size of message segments. The default is 16.

  • msgseg. The maximum number of segments system-wide. Linux does not currently check this limit.

    team bbl



    Performance Tuning for Linux Servers
    Performance Tuning for Linux Servers
    ISBN: 0137136285
    EAN: 2147483647
    Year: 2006
    Pages: 254

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net