[TUHS] mmap, was SCCS, TeamWare, BitKeeper, and Git

Douglas McIlroy douglas.mcilroy at dartmouth.edu
Tue Dec 17 01:40:34 AEST 2024


>> 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:

> ... When multiple processes map the same memory object, they can
> share access to the underlying data.

Notice the weasel word "can". It is not guaranteed that they will do so
automatically without delay. Apparently each process may have a physically
distinct copy of the data, not shared access to a single location.

The Linux man page mmap(2), for example, makes it very clear that mmap
has a cache-coherence problem, at least in that system. The existence
of msync(2) is a visible symptom of the problem.

[Weasel words of my own: I have not read the POSIX definition of mmap.]

Doug


More information about the TUHS mailing list