In Linux, the virtual address space for each process is independent. The virtual address space for each process starts at 0 and extends to task_size-1.
In the system, the kernel allocates 1GB, while the portions available for each user-space process are 3GB.
The process virtual address space consists of a number of regions,
1. Binary code of the currently running code. Text segment.
2. Dynamic library code used by the program.
3. Data segment of the storage area and static variables, Bss,data segment
4. Save a heap that dynamically allocates data
5. Save the local variable and the stack that implements the function call
6. Environment variables and command line arguments.
7. The file content is mapped to a memory map of the virtual address space.
As shown in the specific layout,
If the global variable randomize_va_space is set to 1, then the address space randomization mechanism (ramdom XXX offset) is enabled. Users can deactivate this feature through/proc/sys/kernel/randomize_va_space.
Each process has an instance of Mm_struct (Linux/mm_types.h) that holds the process virtual memory management information.
struct Mm_struct {
struct vm_area_struct *mmap;/* List of VMAs */
struct Rb_root mm_rb;
#ifdef CONFIG_MMU
unsigned long (*get_unmapped_area) (struct file *filp,unsigned long addr, unsigned long len,unsigned long pgoff, unsigned Long flags);
#endif
unsigned long mmap_base;/* base of mmap area */
unsigned long mmap_legacy_base; /* Base of mmap area in bottom-up allocations */
unsigned long task_size;/* size of task VM space */
struct List_head mmlist;/* List of maybe swapped mm ' S.these are globally strung
unsigned long start_code, End_code, Start_data, End_data;
unsigned long start_brk, BRK, Start_stack;
unsigned long arg_start, arg_end, Env_start, env_end;
....
};
Linux Process virtual address space