Pipeline (Unix)
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
Pipeline (Unix)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.
ExamplesSimple exampleIn this example, Pipelines ending in Complex exampleBelow 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. (Some machines have /usr/share/dict/words instead.)
Pipelines in command line interfacesMost Unix shells have a special syntax construct for the creation of pipelines. Typically, one simply writes the filter commands in sequence, separated by the ASCII vertical bar character "|" (which, for this reason, is often called "pipe character" by Unix users). The shell starts the processes and arranges for the necessary connections between their standard streams (including some amount of buffer storage). Error streamBy default, the standard error streams ("stderr") of the processes in a pipeline are not passed on through the pipe; instead, they are merged and directed to the console. However, many shells have additional syntax for changing this behaviour. In the csh shell, for instance, using "|&" instead of "| " signifies that the standard error stream too should be merged with the standard output and fed to the next process. The Bourne Shell can also merge standard error, using 2>&1, as well as redirect it to a different file. PipemillIn the most commonly used simple pipelines the shell connects a series of sub-processes via pipes, and executes external commands within each sub-process. Thus the shell itself is doing no direct processing of the data flowing through the pipeline. However, it's possible for the shell to perform processing directly. This construct generally looks something like: ... which is referred to as a "pipemill" (since the while is "milling" over the results from the initial command.) Example of Pipemill(This example will traverse file directory trees changing the ownership of all files while preserving all permissions, including those that are often stripped off by many versions of the chown command). There are a number of variations of the pipemill construct including: (This example kills the parent processes for zombies owned/created by the user "foo"). Here the while loop is enclosed in a command group (the braces); and preceded by a read command, which effectively "throws away" the first line from the ps command. (Of course, in this particular example it would be harmless to process the header line, as it wouldn't match the "$owner"= test). Note that the other references to the "x" variable are simply being used as placeholders for "throwing away" irrelevant fields from each line. The defining characteristics of a "pipemill" are: some command or series of commands feeds data into a pipe from which a shell while loop reads and processes it. Creating pipelines programmaticallyPipelines can be created under program control.
The To avoid deadlock and exploit parallelism, the process with one or more new pipes will then, generally, call
Named pipes may also be created using ImplementationIn 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. Network pipesTools like netcat and socat can connect pipes to TCP/IP sockets, following the Unix philosophy of "everything is a file". HistoryThe pipeline concept and the vertical-bar notation was invented by Douglas McIlroy, one of the authors of the early command shells, after he noticed that much of the time they were processing the output of one program as the input to another. His ideas were implemented in 1973 when Ken Thompson added pipes to the UNIX operating system.[1] The idea was eventually ported to other operating systems, such as DOS, OS/2, Microsoft Windows, and BeOS, often with the same notation. Although developed independently, Unix pipes are similar to, and were preceded by the 'communication files' developed by Ken Lochner [2] in the 1960's for the Dartmouth Time Sharing System. [3] The robot in the icon for Apple's Automator, which also uses a pipeline concept to chain repetitive commands together, holds a pipe. Other operating systemsThis feature of Unix was borrowed by other operating systems, such as Taos and MS-DOS, and eventually became the pipes and filters design pattern of software engineering. See also
External links
References
cs:Roura (Unix) fr:Tube Unix ko:??? (???) it:Pipeline software pl:Potok (Unix) pt:Pipeline (Unix) sk:Zre?azenie uk:??????? (?????) Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement