Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
OSS Porting Considerations
Open System Services Porting Guide520573-006
6-7
Using Pipes and FIFO Files
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.