I have heard the story of how Douglas Mcllroy came up with the concept and how Ken Thompson implemented it in one night.As far as I understand, pipe is a system call which shares a piece of memory between two processes where one process writes and other reads from.As someone who is not a familiar with OS internals or concepts, I was wondering what exactly is the genius in the story?Is it the idea of two processes sharing memory? Or is it the implementation? Or both?PS: I am aware of the utility of the pipe or how to use it in shell. The question is about concept and implementation of the |
What is the exact ingenuity of Unix pipe
history;unix;process;pipelining
As far as I understand, pipe is a system call which shares a piece of memory between two processes where one process writes and other reads from.Actually, there is no shared memory involved.  The reader and writer are NOT sharing any part of their address space, and they are not using any explicit synchronization.The reading and writing processes are making read and write system calls exactly as they would if they were reading from / writing to a file.  THAT is the genius... the innovation: the notion that (simple) interprocess communication and file I/O can be handled the same way... from the perspective of the application programmer and the user.Once the pipe has been set up, the OS (not application code, or libraries in user-space) takes care of the buffering and the coordination.  Transparently.By contrast, before the invention of the pipe concept, if you needed to do pipeline processing, you would typically have one application write output to a file, and then when it is finished, you would run the second application to read from the file.Alternatively, if you wanted a true pipeline you could code both applications to set up a (real) shared memory segment and use semaphores (or something) to coordinate the reading / writing.  Complicated... and as a consequence not often done.