Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Tunable Kernel Parameters: HP-UX Release 11i Version 1.6 > Chapter 5 Interprocess Communication (IPC) Subsystem

Overview of Message Queue Operations

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

See “Message Parameter Summary” for the list of parameters.

Messages

Messages are small collections of data (400 bytes, for example) that can be passed between cooperating programs through a message queue. Messages within a queue can be of different types, and any process with proper permissions can receive the messages. A receiving process can retrieve the first message, the first message of a given type, or the first message of a group of types. See msgop(2) for more information.

Message Queues

Message queues are implemented as linked lists of data stored in shared memory. The message queue itself contains a series of data structures, one for each message, each of which identifies the address, type, and size of the message plus a pointer to the next message in the queue.

To allocate a queue, a program uses the msgget() system call (see msgget(2)). Messages are placed in the queue by msgsnd() system calls and retrieved by msgrcv() (see msgop(2)). Other operations related to managing a given message queue are performed by the msgctl() system call (see msgctl(2)).

For information about using messages in programs, refer to an advanced UNIX programming text such as Advanced UNIX Programming by Marc J. Rochkind, Prentice-Hall, Inc., ISBN 0-13-011800-1.

Message and Message Queue Management

Message queues and the message header array are located in (swappable) shared memory space. Other data structure arrays necessary for managing them are located in the (nonswappable) kernel space.

Kernel configuration parameters for messages control:

  • Maximum number of message queues on system,

  • Maximum message queue size,

  • Maximum message length,

  • Maximum total combined length of messages in a queue,

  • Maximum number of messages per queue,

  • Maximum number of simultaneous messages system-wide,

  • Maximum size of message header list,

  • Maximum size of free-space map for locating new messages.

IPC messages require the following memory space allocations:

  • Space in the kernel area for message identifiers.

  • Shared memory space for message queues.

  • Shared memory space for message headers.

Message Queues

Queue Size

Each message queue is created with enough space for msgmnb (message queue number of bytes) bytes of messages. Each message contains one or more message segments of msgssz (message segment size) bytes each.

Message Size

To discourage malicious or poorly written programs from consuming excessive message space, individual messages cannot contain more than msgmax (message maximum) bytes per message. Each message is stored in the queue as a series of one or more segments containing msgssz bytes per segment. The number of segments used for a message is the smallest integer that, when multiplied by msgssz, is greater than the total number of bytes in the message.

Queue Space

The total space consumed by all messages in any given queue cannot exceed msgmnb bytes (message-queue maximum number of bytes. This value must not be less than msgmax bytes.

Total Messages

The maximum number of messages that can exist in a queue at any given time depends on the length of individual messages and the constraints of queue size and other factors listed above. However, a system-wide limit is imposed. The total number of messages that can reside on the system at any one time in all queues cannot exceed msgtql (see Message Header Array in “System Globals” below).

System Globals

In addition to the constraints on individual message queues and messages listed in “Message Queues” above, the kernel imposes additional constraints on IPC message management

Message Queue Identifiers

Each message queue has an associated message queue identifier stored in the nonswappable kernel area. msgmni (message maximum number of identifiers) limits the total number of message queues allowed on the system at any given time.

Message Header Array

Each message has an associated message header which is stored in an array in the swappable shared memory area. msgtql (message total quantity limit) defines the total number of messages that can be present system-wide at any given time.

Free Space Management

As messages are sent and received, space to contain those messages is allocated then released, making the space available for other messages. The kernel maintains a resource map which is used for identifying free space to allocate for new messages. The size of this map is controlled by the msgmap parameter.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2000-2003 Hewlett-Packard Development Company, L.P.