Can UNIX pipe connections be compiled?
Tom Christiansen
tchrist at convex.COM
Sun Jan 20 17:16:58 AEST 1991
>From the keyboard of uunet!bria!mike (Michael Stefanik):
:Unless I'm reading you wrong, you seem to think that pipes are some coded
:mechanism for communication between processes; it isn't. An (anonymous)
:pipe is a temporary entity created in the filesystem by the kernel on
:behalf of two related processes that want to communicate.
No, it's not. On BSD systems, pipe(2) is implemented as a
semi-disabled version of socketpair(2). It's all IPC -- no
filesystem activity is involved. All the work is not a Vax,
nor is it SysV.
:It is useful
:to think of a pipe as a regular file, in which one process is writing to on
:one end, and another process is reading from on the other end.
:
:Typically, a pipe can buffer up to about 5K of data flowing through the
4k on my system.
:pipe. When the pipe "fills up", the writing process is blocked until
:the reading process reads from the pipe. Similarly, the reading process
:will block on an empty pipe, until the writing process writes something.
:Should the reading process die and the writing process attempt to write
:on the pipe, a signal will be sent (SIGPIPE) to the offending writing
:process (which tells it that there is no longer anything out there to
:read from the pipe). If this wasn't done, the writing process would deadlock
:when the pipe buffer filled, waiting for a reading process that no longer
:existed.
This is all true and useful information. (As far as I know.)
:So, after this brief overview of piping, the answer is, no, you cannot
:"compile" pipes to increase the speed of reads and writes to the pipe.
But you can often rearrange your program so it doesn't shove the data
through a bunch of processes' address spaces. A good example is the slow
old makewhatis script, which runs much faster when coded do to the work
entirely in one process.
--tom
--
"Hey, did you hear Stallman has replaced /vmunix with /vmunix.el? Now
he can finally have the whole O/S built-in to his editor like he
always wanted!" --me (Tom Christiansen <tchrist at convex.com>)
More information about the Comp.unix.questions
mailing list