[TUHS] mmap, was SCCS, TeamWare, BitKeeper, and Git
John Levine
johnl at taugh.com
Mon Dec 16 09:05:07 AEST 2024
It appears that Douglas McIlroy <douglas.mcilroy at dartmouth.edu> said:
>Unix originally imitated the Multics file system, but not the universal
>memory. mmap(2) weakly imitates universal memory by allowing a process
>to nominally incorporate a portion of a file into the process address space
>at page-level granularity. However, an update is guaranteed to be visible
>to the file and other processes only upon specific request.
>
>Does anyone know whether there are implementations of mmap that
>do transparent file sharing? It seems to me that should be possible by
>making the buffer cache share pages with mmapping processes.
These days they all do. The POSIX rationale says:
A memory object can be concurrently mapped into the address space of one or more
processes. The mmap( ) and munmap( ) functions allow a process to manipulate their address
space by mapping portions of memory objects into it and removing them from it. When
multiple processes map the same memory object, they can share access to the underlying
data.
"Memory object" includes disk files.
There are MAP_SHARED and MAP_PRIVATE flags that say whether changes are written
through or copy-on-write to local private pages.
R's,
John
More information about the TUHS
mailing list