Process Virtual Memory
1 Process address space
The process virtual memory address space starts at 0, terminates at Task_size-1, which is the kernel space, the total address space is divided by 3:1, the user process cannot access the kernel space, and if there is no protocol, a user process cannot access the space of other processes.
1.1 Layout of the process address space
A text segment of the current run code
Code of the dynamic library used by the B program
c Storage of global variables and dynamically generated data heap
D Save the stack of local variables and function/procedure calls
e environment variables and command line arguments
F file content mapped to memory mappings in virtual memory space
Each process has a mm_struct that holds the memory management information for the process.
Classic Layouts
Mmap addresses are typically 1/3 of virtual space
New layout
If the stack size is set to Unrestricted, select Use classic layout, otherwise use the new layout
1.2 Memory Map
In Mm_struct, the process virtual space information is represented by multiple regions, each region is described by Vm_area_struct, and a red-black tree is used to quickly find the area before the area when adding an area without having to scan the entire list
void* mmap (void* start,size_t length,int prot,int flags,int fd,off_t offset); int Munmap (void* start,size_t length);
The Mmap function creates a length at the beginning of the virtual address space, and the access rights are defined as prot
Process Virtual Memory