Mmap () internal

It is well known that the most significant function of mmap () is that file associations are shared among many processes. But it is no less widely known that each process has its own address space.

The question is where are memmapped files (more precisely, its data) stored, and how can processes access this memory? I do not mean * (pa + i) and other high-level materials, but I mean the insides of the process.

+3
source share
5 answers

This happens at the virtual memory management level in the operating system. When you store a memory card, the memory manager basically processes the file as if it were the swap space for the process. When you access pages in the address space of virtual memory, the memory mapper must interpret and map them to physical memory. When you cross the page border, this can lead to a page crash, and at this time, the OS must map a piece of disk space to a piece of physical memory and enable the display of memory. With mmap, it simply does this from your file instead of its own swap space.

If you need detailed information on how this happens, you must tell us which operating system you are using, as the implementation details vary.

+8

, :

, , . (VMM) , .

, . , , . , . , . , , . / / , .

, , , .

, . , , .

+2

, , mmap() ( , ).

, OS : mmap().

0

, . , . proccesses , ( ).

, . , , .

0

- , , - - ram (initramfs), , , ​​ , .

, . , vm_are_struct, . mmap vm_area_struct , .

mmap . , , . , malloc. mm_struct pgd_t ( ) .

0
source

Source: https://habr.com/ru/post/1706751/


All Articles