In Unix-like computer operating systems, a pipeline is the original software pipeline: a set of processes chained by their standard streams, so that the output of each process (stdout) feeds directly as input (stdin) of the next one. Each connection is implemented by an anonymous pipe. Filter programs are often used in this configuration. The concept was invented by Douglas McIlroy for Unix shells and it was named by analogy to a physical pipeline.
Below is an example of a pipeline that implements a kind of spell checker for the web resource indicated by a URL. An explanation of what it does follows.
curl http://en.wikipedia.org/wiki/Pipeline | \ sed 's///g' | \ tr 'A-Z ' 'a-z\n' | \ grep '*' | \ sort -u | \ comm -23 - /usr/dict/words
Pipelines can be created under program control.
The pipe() system call asks the operating system to construct a new anonymous pipe object.
This results in two new, opened file descriptors in the process: the read-only end of the pipe, and the write-only end.
The pipe ends appear to be normal, anonymous file descriptors, except that they have no ability to seek.
To avoid deadlock and exploit parallelism, the process with one or more new pipes will then, generally, call
fork() to create new
processes. Each process will then close the end(s) of
the pipe that it will not be using before producing or consuming any data.
Alternatively, a process might create a new thread and use the pipe to communicate between them.
Named pipes may also be created using mkfifo() or mknod() and then presented as the input or output file to programs as they are invoked. They allow multi-path pipes to be created, and are especially effective when combined with standard error redirection, or with tee.
In most Unix-like systems, all processes of a pipeline are started at the same time, with their streams appropriately connected, and managed by the scheduler together with all other processes running on the machine. An important aspect of this, setting Unix pipes apart from other pipe implementations, is the concept of buffering: a sending program may produce 5000 bytes per second, and a receiving program may only be able to accept 100 bytes per second, but no data are lost. Instead, the output of the sending program is held in a buffer, or queue. When the receiving program is ready to read data, the operating system sends it data from the buffer, then removes that data from the buffer. If the buffer fills up, the sending program is suspended (blocked) until the receiving program has had a chance to read some data and make room in the buffer.
The robot in the icon for Apple's Automator, which uses also uses pipeline concept to chain repetitive commands together, holds a pipe as recognition of the application's Unix heritage.
Main article: pipeline (software)
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Pipeline (Unix)".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world