Are sharing a memory-mapped file and sharing a memory region implemented based on each other? The following two quotes seem to say so, and seem a chicken-egg problem to me.
Operating System Concepts introduces sharing a memory-mapped file in the following. Do the multiple processes share the same file by sharing the same physical memory region holding the content of the file?
Multiple processes may be allowed to map the same ﬁle concurrently, to allow sharing of data. Writes by any of the processes modify the data in virtual memory and can be seen by all others that map the same section of the ﬁle. Given our earlier discussions of virtual memory, it should be clear how the sharing of memory-mapped sections of memory is implemented: the virtual memory map of each sharing process points to the same page of physical memory—the page that holds a copy of the disk block. This memory sharing is illustrated in Figure 9.22.
It also introduces shared memory in the following.
Do multiple processes share a memory region by sharing a memory-mapped file?
Does a "memory-mapped file" reside on disk or main memory? I think it is on the disk, but "The memory-mapped ﬁle serves as the region of shared memory between the communicating processes" seems to mean that it resides in main memory.
Quite often, shared memory is in fact implemented by memory mapping ﬁles. Under this scenario, processes can communicate using shared memory by having the communicating processes memory-map the same ﬁle into their virtual address spaces. The memory-mapped ﬁle serves as the region of shared memory between the communicating processes (Figure 9.23).