The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* Re: [TUHS] mmap origin (was Systematic approach to command-line interfaces)
@ 2021-10-01 11:36 Paul Ruizendaal
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Ruizendaal @ 2021-10-01 11:36 UTC (permalink / raw)
  To: TUHS main list

Dan wrote:

> 3BSD and I think 4.1BSD had vread() and vwrite(), which looked like 
> regular read() and write() but accessed pages only on demand. I was a 
> grad student at Berkeley at the time and remember their genesis. Bill 
> and I were eating lunch from Top Dog on the Etcheverry Hall plaza, and 
> were talking about memory-mapped I/O. I remember suggesting the actual 
> names, perhaps as a parallel to vfork(). I had used both TENEX and 
> Multics, which both had page mapping. Multics' memory-mapped segments 
> were quite fundamental, of course. I think we were looking for something 
> vaguely upward compatible from the existing system calls. We did not 
> leap to an mmap() right away just because it would have been a more 
> radical shift than continuing the stream orientation of UNIX. I did not 
> implement any of this: it was just a brainstorming session.

Thank you for reminding me of these. 

On a substrate with a unified buffer cache and copy-on-write, vread/vwrite would have been very close to regular read/write and maybe could have been subsumed into them, using flags to open() as the differentiator. The user discernible effect would have been the alignment requirement on the buffer argument.

John Reiser wrote that he "fretted” over adding a 6 argument system call. Perhaps he was considering something like the above as the alternative, I never asked.

I looked at the archives and vread/vwrite were introduced with 3BSD, present in 4BSD but marked deprecated, and absent from 4.1BSD. This short lifetime suggests that using vread and vwrite wasn’t entirely satisfactory in 1980/81 practice. Maybe the issue was that there was no good way to deallocate the buffer after use.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [TUHS] mmap origin (was Systematic approach to command-line interfaces)
  2021-09-30  9:01 Paul Ruizendaal via TUHS
@ 2021-09-30 12:56 ` Dan Halbert
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Halbert @ 2021-09-30 12:56 UTC (permalink / raw)
  To: tuhs

On 9/30/21 5:01 AM, Paul Ruizendaal via TUHS wrote:
> 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.
>
3BSD and I think 4.1BSD had vread() and vwrite(), which looked like 
regular read() and write() but accessed pages only on demand. I was a 
grad student at Berkeley at the time and remember their genesis. Bill 
and I were eating lunch from Top Dog on the Etcheverry Hall plaza, and 
were talking about memory-mapped I/O. I remember suggesting the actual 
names, perhaps as a parallel to vfork(). I had used both TENEX and 
Multics, which both had page mapping. Multics' memory-mapped segments 
were quite fundamental, of course. I think we were looking for something 
vaguely upward compatible from the existing system calls. We did not 
leap to an mmap() right away just because it would have been a more 
radical shift than continuing the stream orientation of UNIX. I did not 
implement any of this: it was just a brainstorming session.

Dan H

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [TUHS] mmap origin (was Systematic approach to command-line interfaces)
@ 2021-09-30  9:01 Paul Ruizendaal via TUHS
  2021-09-30 12:56 ` Dan Halbert
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Ruizendaal via TUHS @ 2021-09-30  9:01 UTC (permalink / raw)
  To: TUHS main list


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-01 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 11:36 [TUHS] mmap origin (was Systematic approach to command-line interfaces) Paul Ruizendaal
  -- strict thread matches above, loose matches on Subject: below --
2021-09-30  9:01 Paul Ruizendaal via TUHS
2021-09-30 12:56 ` Dan Halbert

The Unix Heritage Society mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/tuhs

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 tuhs tuhs/ https://inbox.vuxu.org/tuhs \
		tuhs@minnie.tuhs.org
	public-inbox-index tuhs

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.tuhs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git