Regular pipe vs. Named Pipe

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Jun 10 09:16:07 AEST 1991


In article <14079 at dog.ee.lbl.gov> torek at elf.ee.lbl.gov (Chris Torek) writes:
> In article <1991Jun7.195953.27744 at digi.lonestar.org>
> cfoughty at digi.lonestar.org (Cy Foughty) writes:
> >What are the differences between a regular pipe and a named pipe?
> The main difference is that one has a name and one does not.

Pipes are part of UNIX. Named pipes aren't. Named pipes appear in most
(all?) System V releases and some BSD-derived releases, notably SunOS
and Ultrix (where they are also called ``ports''). Named pipes are
formalized by POSIX, with a slightly different behavior from that in any
existing system. Pipes in POSIX are defined as special cases of named
pipes. Pipes under Ultrix are not special cases of named pipes; they're
implemented separately. Pipes under straight BSD are special cases of
UNIX-domain sockets. (You can see most of this from the output of my pff
program... ah, shaddap, Dan.)

Basically, pipes work the same way everywhere, and named pipes don't.
The name part of named pipes is their least portable aspect. Never use
them in a long-lived program if you can use any other communications
mechanism.

> >Which type of pipe is faster and by how much?
> >Which is faster, a named pipe or a message queue?
> >Does a named pipe always go to disk or only when the allocated
> >memory is exhausted?
> All of these are implementation-dependent.

On systems where pipes and named pipes use the same mechanism, neither
one is faster (obviously). Under Ultrix they appear to run at the same
speed anyway. Message queues are uniformly slower in my tests. On
systems where named pipes are implemented in terms of sockets, they
don't go to disk; under at least some versions of Ultrix they do go to
disk.

Basically, what Chris said.

---Dan



More information about the Comp.unix.internals mailing list