On Wed, Sep 29, 2021 at 09:40:23AM -0700, Greg A. Woods wrote:
I think perhaps the problem was that mmap() came too
soon in a narrow
sub-set of the Unix implementations that were around at the time, when
many couldn't support it well (especially on 32-bit systems -- it really
only becomes universally useful with either segments or 64-bit and
larger address spaces). The fracturing of "unix" standards at the time
didn't help either.
Perhaps these "add-on hack" problems are the reason so many people think
fondly of the good old Unix versions where everything was still coming
from a few good minds that could work together to build a cohesive
design. The add-ons were poorly done, not widely implemented, and
usually incompatible with each other when they were adopted by
additional implementations.
mmap() did come from those days and minds.
The first appearance of mmap() was in 32V R3, done by John Reiser in 1981. This is the
version of 32V with full demand paging; it implemented a unified buffer cache. According
to John, that version of mmap() already had the modern 6 argument API. John added mmap()
because he worked with Tenex a lot during his PhD days and missed PMAP. He needed some 6
months to design, implement and debug this version of 32V as a skunkworks project.
I am trying to revert early VAX SVr1/r2 code to get a better view of what 32V R3 looked
like, but unfortunately I did not have much time for this effort in last couple of months.
It would seem that 32V R3 assumed that disk blocks and memory pages were the same size
(true on a 1980 VAX) and with that assumption a unified buffer cache comes natural in this
code base.
For 4.2BSD initially Joy cs. had a different approach to memory mapped files in mind (see
the 1981 tech report #4 from CSRG). By the time of 4.2BSD’s release the manual defined a
mmap() system call, but it was not implemented and it appears to have been largely
forgotten until SunOS 4 and dynamic libraries six years later.
In the SysV lineage it is less clear. For sure mmap() is not there, but the first
implementation of the shmem IPC feature might derive from the 32V R3 code. On the inside,
SVr2 virtual memory appears to implement the segments (now called regions) that Joy
envisaged for 4.2BSD but did not implement.
CB Unix had a precursor to shmem as well, where a portion of system core was reserved for
shared memory purposes and could be accessed either via the /dev/mem device or could be
mapped into the PDP-11 address space (using 1 of the 8 segment registers for each map).
Here too the device and the map were unified.
So far, I have not come across any shared library implementations or precursors in early
Unix prior to SunOS 4.
Paul