Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!snorkelwacker!think!samsung!xylogics!world!madd From: madd@world.std.com (jim frost) Newsgroups: comp.sys.apple2 Subject: Re: pipes (implementation thereof) Message-ID: <1990Mar13.022324.19402@world.std.com> Date: 13 Mar 90 02:23:24 GMT References: <6673@hydra.gatech.EDU> <1990Mar5.234421.396@world.std.com> <2218@tellab5.tellabs.com> <14398@reed.UUCP> Organization: Saber Software Lines: 42 reeder@reed.UUCP (Doug Reeder) writes: > IMHO, the best way to implement pipes is as follows: start the last >program, and let it run along until it requests a character from the >standard input from the OS. The OS then starts up the next to last program, >and lets it run untill it sends a character to standard output (by making an >OS call) The OS then switches back to the last program. If the next to last >program requests a character from the standard input, the OS switches to the >previous program, and runs it until it gets a character, and so on back >through the chain. The advantage of this system is that you never have to >interrupt a program This is a poorer technique as it degrades immediately into the traditional buffer-output-until-buffer-full-or-done technique, and additionally requires all processes to be active at one time for at least some of the processing. Consider that in a pipe not much is going to be done until there is input from somewhere. Each of the processes along the pipe depends on its supplier for that input, back to the head process of that pipe. Your technique would require backtracking to that head process before meaningful processing could commence, at which time the data would flow back along the pipe in exactly the same manner in which it does in traditional piping schemes. You've gained nothing, since your technique degraded immediately to the traditional. What have you lost? At the start, all processes along the pipe *must* be active before any data goes through it. For a long pipe this will be a lot of resources. In the traditional method, adjusting the buffer size can reduce the number of processes which must be active. In the degenerate case, where the buffer size is infinite, only one process at a time needs to be active. This degenerate case is what's used in MS-DOS and some other single-tasking OS's -- you write all the output to disk then start the next process in the pipe using the disk file as input. Happy hacking, jim frost saber software jimf@saber.com