5 ms·
Pipes are commonly used when the right side is consuming the output of the left side. That introduces serialization at least insofar as the right side is forced
by muststopmyths 8y ago
Pipes are commonly used when the right side is consuming the output of the left side. That introduces serialization at least insofar as the right side is forced to wait for input.
You could replace the | with an &; and get the same behavior because nothing in the 2nd stage depends on the first stage of the pipe.
In my old man grumbling at clouds voice: This is not arcane.
- yakshaving_jgt 8y agoPerhaps not arcane, but at least somewhat counterintuitive if one's mind is too invested in the "pipe" analogy.
- sjy 8y agoBut physical pipes run in parallel too! If you have a pipe full of water, and you push some more water in one end, there is an instant effect at the other end. If it's empty, then sequentiality is introduced because it takes time for the water to flow through the pipe. That's how a Unix pipe works – (the processes at) both ends of the pipe come into existence at the same time, but if the right side is waiting for input (the pipe buffer is empty), it won't do anything until the left side has produced output.