Chris's Wiki :: blog/unix/BufferedPipes Commentshttps://utcc.utoronto.ca/~cks/space/blog/unix/BufferedPipes?atomcommentsDWiki2019-03-08T16:25:06ZRecent comments in Chris's Wiki :: blog/unix/BufferedPipes.By Chris Siebenmann on /blog/unix/BufferedPipestag:CSpace:blog/unix/BufferedPipes:327a37b0ce30536d86f96ab46fefb91a930665f1Chris Siebenmann<div class="wikitext"><p>To be clear, the PDP-11 series had virtual memory from the start (with
memory mapping and memory protection); it just didn't have <em>paged</em>
virtual memory. Research Unix swapped whole programs in and out as needed,
and you're right, a swapped out process would complicate trying to copy
data directly to it. Clearly you're going to need a kernel buffer some
of the time so you might as well use it all of the time, especially since
Research Unix very much believed in simple solutions.</p>
<p>(According to <a href="https://www.bell-labs.com/usr/dmr/www/odd.html">Dennis Ritchie's information</a>, very early versions
of Unix did run on a PDP-11/20 without any memory protection. It was
apparently about as much of a pain for a multi-user machine as you'd
expect.)</p>
</div>2019-03-08T16:25:06ZBy Alan on /blog/unix/BufferedPipestag:CSpace:blog/unix/BufferedPipes:06f6e162e8df90b0cfc575b9252f2087a8339c50Alanhttps://twitter.com/sourcejedi<div class="wikitext"><p>Huh. That <em>is</em> an interesting question...</p>
<p>Linux used per-process virtual addresses from the start. The kernel could not just memcpy() from one process to another. There are primitives copy_from_user and copy_to_user. From that point of view, you had to use a kernel buffer. (Otherwise, I guess you would have to implement some special case cross-process mapping code, that is not used anywhere else?). And then enforcing the unbuffered semantics would have been less natural: extra complexity without obvious gain.</p>
<p>Did MMU-less UNIX implement, or consider implementing, swapping processes to disk? That would be an equivalent reason, that you should avoid directly reading or writing the peer process's memory.</p>
</div>2019-03-08T15:45:34ZBy Aristotle Pagaltzis on /blog/unix/BufferedPipestag:CSpace:blog/unix/BufferedPipes:0bc44dc201ded5a1b02ae4b1c790647173376387Aristotle Pagaltzishttp://plasmasturm.org/<div class="wikitext"><p>If a pipe write doesn’t trigger a task switch I’d assume it’s not for memory savings from allowing the process to exit but for overhead reduction from, well, reduced task switching. (Esp. the older the architecture is for which the kernel is written.) Go channels are in-process so it’s a different situation. Intuitively I’d be more surprised to see a kernel IPC stream interface <em>without</em> buffering than one with, though I can’t articulate the why very well beyond a hand-waved “overhead reduction”. I wonder if the actual V7 code bears this out.</p>
</div>2019-03-08T05:44:13Z