Both an unnamed pipe buffer and a fifo file exhibit nearly identical behavior. They both are opened simultaneously for reading and writing. Both buffers are circular; when reading or writing beyond the end of the buffer, the read or write buffer pointer is reset to the beginning of the buffer and I/O continues if there is room left (when writing) or data left (when reading). Data is written to the buffer sequentially, and placed in the buffer immediately after previously written bytes. The write buffer pointer is advanced after each byte that is written. Data is read from the buffer sequentially, and the read buffer pointer is advanced after each byte that is read. Reader processes are suspended when there is no more data to be read from the buffer (i.e., both the read and write buffer pointers are in the same position in the buffer). The processes are resumed when data is written to the buffer. Writer processes are suspended when the buffer becomes full. The processes are resumed when data is read from the buffer. If all writer processes close their end of the buffer, the reader processes get the value EOF (end-of-file) during their next read operations. If all reader processes close their end of the buffer, the writer processes receive the SIGPIPE signal from the Unix operating system.
There are two main differences between the two mechanisms. The first is the size of the buffer. An unnamed pipe buffer in the Unix kernel ranges between 4K and 8K bytes, depending on the particular version of Unix. A fifo file is a named file in the file system, and therefore it has nearly unlimited size. Size is the distinctive characteristic for selecting a particular PipeType value. The second main difference is the way that the buffers are created. An unnamed buffer is created with the pipe function in the C standard library. Two file descriptors are returned to the application as a result of the call; they are both open - one for reading and one for writing. A named fifo file is created in the file system with either the mknod or mkfifo function in the C standard library (most Unix systems have the mknod function; only a few have the mkfifo function - the usage of both functions is nearly identical). Once the fifo file is created, it must be opened manually (i.e., using the open function in the C standard library) by both the reader processes and the writer processes. All reader processes will be suspended until at least one process opens the fifo file for writing, and vice versa.
The default value for the PipeType property is named.
Subsequent specifications of the PipeType property in a single property list replace earlier specifications (i.e., the last specification is the one that the UniCon compiler uses).
CONNECTOR Unix_Pipe PROTOCOL IS TYPE Pipe PIPETYPE (unnamed) ROLE Source IS Source ROLE Sink IS Sink END PROTOCOL IMPLEMENTATION IS BUILTIN END IMPLEMENTATION END Unix_PipeBelow is another example of a specification of a PipeType property. It is embedded in an instantiation of the above Pipe connector:
USES My_Pipe PROTOCOL Unix_Pipe PIPETYPE (named) END My_PipeThe PipeType value named in the My_Pipe Pipe instantiation overrides the PipeType value unnamed in the Unix_Pipe Pipe definition.
Author:
Last Modified: May 12, 1996