Pipes

Very similar to messages, but in this case there is even less structure, the information which flows through a pipe is just a stream of unstructured bytes. Typically a pipe is implemented as a fixed size buffer, with one process able to write into the buffer, and one process able to read from the buffer.

Put like that, it is easy to see how a solution to the producer-consumer problem could be used to implement pipes.

In UNIX, pipes are accessed just like files, using the same system calls to write data to a pipe and read data from a pipe as those for reading and writing files. In UNIX, a process which creates a pipe receives two identifiers, one for the reading end, one for the writing end. In a typical case, the creating process would then fork off two child processes, passing to one end of the pipe to one child, and the other end of the pipe to the other child. The two child processes could then communicate.

Pipes may also be generalised to work between machines, with each end of the pipe on a different machine. In this context, it is usually called a connection; the ends of the pipe are called sockets.


last updated 13 February 1998