Messages


The IPC messages facility allows users to define a message queue ID number ( essentially a mailbox) that can be used to hold messages for another process. Each message may have an associated type, which makes finding special (high-priority) mail easier. The queues themselves are configurable and probably need to be expanded if any major use is going to be made of them.

Tunable parameters for messages

Tunable parameters in Solaris 2 are listed in Appendix A of Administering Security, Performance, and Accounting . SunOS 4.x discusses them in the System and Network Administration Manual in the chapter "Advanced Administration Topics." They are somewhat different.

For Solaris 2, the following variables are defined as tunable.

  • msgmap ” Defines the number of entries in the free space map for messages. This map keeps track of free message segments.

  • msgmax ” Is a maximum byte count for an individual message.

  • msgmnb ” Keeps a queue from growing too large. This variable is the maximum byte count for all messages on that queue.

  • msgmni ” Defines the total number of message queues allowed. This variable allocates the msqid_ds data structures (queue headers).

  • msgssz ” Defines the message segment size. Messages are built of small segments (which should be an even multiple of the system word size). The total memory pool allocated to messages is derived from the total segment allowance multiplied by the size of each segment. A message will be built from the needed number of contiguous segments, allocated from the message map. The pointer to the message text will be derived from the starting segment number.

  • msgtq ” Is a maximum for the number of messages that may be outstanding. This variable defines the number of msg header structures that are allocated.

  • msgseg ” Defines the total number of message segments to allocate. This variable is a short and must be kept less than 32768 to avoid sign extension problems.

For SunOS 4.x kernels , some defined values can be overridden by options specified in the configuration file. Those options are:

  • MSGPOOL ” Defines the total amount of space available for messages. This will automatically be divided up into 8-byte segments. (In Solaris 2, this number is derived from the message segment quantity and size.)

  • MSGMNB ” Is the maximum number of bytes allowed on any one queue.

  • MSGMNI ” Is the total number of message queues ( msgid instances).

  • MSGTQL ” Defines the total number of message headers (the maximum number of messages that can be waiting on all the message queues).

  • MSGMAX ” Is listed as "assumed not to require tuning." It is defined by default as the total number of bytes available for messages. Thus, it is possible to have one message use up the entire memory pool. It may be worth restricting MSGMAX if user programs have the potential to write massive missives.

Message tuning for both SunOS 4.x and Solaris 2 must be based on the number of queues desired, the type of messages being sent (small ones or large ones), and the expected number of them.

Internal variables

Messages are implemented in essentially the same way in Solaris 2 and in SunOS 4.x. The internal variables, structures, and routines are essentially the same.

Variables of interest are:

  • msg ” Points to the space available for messages. This is the "pool" of segments.

  • msgmap ” Defines the list of free space in terms of individual segments.

  • msgh ” Points to the start of the pool of message headers ( msg structures).

  • msgfp ” Points to a list of individual message headers, which are linked together. This is a free list of unused msg structures.

  • msgque ” Points to the list of queue headers, which contain pointers to the beginning and end of the individual queues.

Internal structures

The important internal structures are defined in /usr/include/sys/msg.h for both Solaris 2 and SunOS 4.x systems. These include the msgid_ds data structure, which is the queue head, the msg structure, which identifies specific message parameters, including type and length, and the msginfo structure, which contains the message system parameters.

Functions

The handling of messages follows closely the semaphore routines, but messages are significantly simpler to deal with.

  • msginit() ” Performs initialization, memory allocation (in Solaris 2), and sets up the map information.

  • msgconv() ” Converts a message ID from a user into a pointer to a queue header ( msg_ds ) structure.

  • msgsys() ” Is the front end to the system calls.

  • msgctl() , msgget() , msgrcv() , and msgsnd() ” Performs the actual system calls.

  • msgfree() ” Takes a message that has been received and frees up the segments and the message header.



PANIC. UNIX System Crash Dump Analysis Handbook
PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)
ISBN: 0131493868
EAN: 2147483647
Year: 1994
Pages: 289
Authors: Chris Drake

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