PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)

In early versions of UNIX, pipes are implemented as kernel buffers and are basically unidirectional: You can have only one reader and one writer on a pipe. BSD UNIX changed this to use sockets (network connectors). In SunOS 4.x, pipes are in fact implemented internally as UNIX domain socket connections.

In Solaris 2, pipes are implemented by using STREAMS, so they are also true bidirectional data paths. They look like two Stream heads linked together, with no device driver or modules to get in the way. Data that is written to a pipe will be turned into a Streams message and sent off to the queue for the other end. The following figure illustrates the concept.

Figure 25-3. Pipe implementation

A user still gets two file descriptors from a pipe(2) system call. A write to the first descriptor delivers data that can be read from the second descriptor at the other end of the pipe, and vice versa ” with the distinction that the data paths are separated. A process cannot read data that it has written, as could be done with old UNIX pipes.

Since a pipe is just like any other Stream, it can have modules pushed on it. There is, however, a concept of a " midpoint " in pipes, so a module must be popped off the same end from which it was pushed. There are also some tricky semantics regarding data flow ( specifically with regard to flushing data from the stream). The STREAMS Programmer's Guide has more information if you want to play with these.

Категории