Application programming

Interprocess communication

Pipes, named pipes, and signals are all forms of interprocess communication. Business applications running on a UnixWare system, however, often need more sophisticated methods of communication. In applications, for example, where fast response is critical, a number of processes may be brought up at the start of a business day to be constantly available to handle transactions on demand. This cuts out initialization time that can add seconds to the time required to deal with the transaction. To go back to the ticket reservation example again for a moment, if a customer calls to reserve a seat on the 5 o'clock flight to Detroit, you do not want to have to say, ``Yes, sir; just hang on a minute while I start up the reservations program.'' In transaction-driven systems, the normal mode of processing is to have all the components of the application standing by waiting for some sort of an indication that there is work to do.

To meet requirements of this type, UnixWare offers a set of nine system calls and their accompanying header files, all under the umbrella name of interprocess communications (IPC).

The IPC system calls come in sets of three; one set each for messages, semaphores, and shared memory. These three terms define three different styles of communication between processes:

Communication is in the form of data stored in a buffer. The buffer can be either sent or received.

Communication is in the form of positive integers with a value between 0 and 32,767. Semaphores may be contained in an array the size of which is determined by the system administrator. The default maximum size for the array is 25.

shared memory
Communication takes place through a common area of main memory. One or more processes can attach a segment of memory and as a consequence can share whatever data is placed there.
The sets of IPC system calls are:

msgget semget shmget
msgctl semctl shmctl
msgop semop shmop
The ``get'' calls each return to the calling program an identifier for the type of IPC facility that is being requested.

The ``ctl'' calls provide a variety of control operations that include obtaining (IPC_STAT), setting (IPC_SET) and removing (IPC_RMID), the values in data structures associated with the identifiers picked up by the ``get'' calls.

The ``op'' manual pages describe calls that are used to perform the particular operations characteristic of the type of IPC facility being used. msgop has calls that send or receive messages. semop (the only one of the three that is actually the name of a system call) is used to increment or decrement the value of a semaphore, among other functions. shmop has calls that attach or detach shared memory segments.

Where to find more information

See ``Interprocess communication'' for a detailed description of IPC, with many code examples that use the IPC system calls. An example of the use of some IPC features is included in the liber application in ``Interprocess communication''.

Next topic: Symbolic links
Previous topic: Where to find more information

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004