Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)

There is no message-queue support between the Guardian and OSS environments with the OSS
message-queue function calls.
The services provided by message queues also can be provided using other OSS IPC mechanisms
that are generally available on all UNIX systems. The following IPC mechanisms can be used if
you need to modify your application program to provide the equivalent feature: pipes, FIFOs, and
OSS sockets.
If the code you are porting uses message queues, you can redesign your code to use the Guardian
message system. The Guardian message system is available through the use of $RECEIVE and the
WRITEREAD Guardian procedure call.
The semantics of all these alternatives to message queues are different, so this must be considered
when redesigning this portion of your code. The NonStop system supports both user-level
(recommended) and system-level routines.
Refer to the corresponding reference pages, either online or in the Open System Services System
Calls Reference Manual, for details on using OSS message-queue functions.
Message Queues and Process Creation Functions
The message-queue identifiers returned by the msgget() function are not associated with any
process, and information about the identifiers is not maintained in the context of any user process.
These message-queue identifiers are global to the system, so the following do not handle the
message-queue identifiers, as they do for file descriptors and other process attributes:
The fork() function
The exec set of functions
The tdm_fork() function
The tdm_execve set of functions
The tdm_spawn set of functions
Using Pipes and FIFO Files
A pipe redirects the output of one process to the input of another; a pipe is an unnamed FIFO file.
Pipes are created programmatically by invoking the pipe() function (discussed in this subsection),
or interactively with the shell pipe character (|). Refer to the Open System Services User’s Guide
for information on creating pipes interactively.
FIFO files are always read and written in a first-in, first-out (FIFO) manner. FIFOs are named pipe
files, and they can appear only in the OSS name space. (They have the same meaning as in the
UNIX file systems.) This subsection discusses creating pipes and FIFO files in the OSS environment,
as well as performance considerations.
Pipe Implementation for Single-Processor System
A parent process can create a pipe by calling the pipe() function, which returns a pair of file
descriptors: one for writing and one for reading. The parent process calls fork() or tdm_fork()
to create a child process in the same processor. The child process shares all the parent’s file
descriptors. When the parent process creates a pipe, the pipe management is done in the same
processor in which the parent is running. If the child process is created in the same processor, all
pipe I/O between the two processes is handled within that processor.
When the parent and child processes are in the same processor, there is very little processing
involved to create a pipe: it is all done in memory with a pipe buffer. Because there is no interaction
with the OSS pipe server, the operation is quick and uses very few system resources.
Using a Pipe Across Processors
In the OSS environment, there is one OSS pipe server for each processor. The OSS pipe server
process is started at reload time and handles all pipe-creation tasks per processor; it is the destination
Using Interprocess Communication (IPC) Mechanisms 91