Virtual process memory

来源:互联网 发布:informix数据导入 编辑:程序博客网 时间:2024/05/22 13:23

terms

reverse mapping technique :track which virtual pages are backed by which physical page.

page fault handling :allows filling the virtual address space with data from block devices on demand.

organization of physical memory :

management of the virtual kernel address space :


introductions

reasons why to manage the virtual user address space is more complex than managing kernel address space:

Each application has its own address space that is segregated from all other applications.

Usually only a few sections of the large linear address space available to each userspace process are actually used, and they may also be some distance from each other. The kernel needs data structures to efficiently manage these (randomly) spread sections.

Onlythe smallest part of the address space is directly associated with physical pages. Infrequently used parts are linked with pages only when necessary.

The kernel has trust in itself, but not in user processes. For thisreason, each operation to manipulate user address space is accompanied by various checks to ensure that programs cannot acquire more rights than are due to them and thus endanger system stability and security.

The fork-exec model used under Unix to generate new processes(described in Chapter 2) is not very powerful if implemented carelessly. The kernel must therefore concentrate on managing user address spaces as efficiently as possible by resorting to a few tricks.


assumption

Most of the ideas discussed below are based on the assumption that thesystem has a memory management unit (or MMU) that supports the use of virtual memory .


the virtual address space of each process

starts: address 0

end: TASK_SIZE – 1


system integrity

user programs may access only the lower part of the overall address space but not the kernel part. Neither is it possible for a user process to manipulate

parts of the address space of another process without previous‘‘agreement,’’ simply because these parts

are invisible to it.

The contents of the virtual address space portion of the kernel are always the same regardless of which user process is currently active.

The virtual address space is made up of many sections of varying sizes that serve different purposes and must be handled differently .


Layout of the Process Address Space

The virtual address space is populated by a number of regions:

The binary code of the code currently running. This code is normally referred to as text and the area of virtual memory in which it is located as a text segment.

The code of dynamic libraries used by the program.

The heap where global variables and dynamically generated data are stored.

The stack used to hold local variables and to implement function and procedure calls.

Sections with environment variables and command-line arguments.

Memory mappings that map the contents of files into the virtual add ressspace.


instance holds memory management information for the

process:




<mm_types.h>

struct mm_struct {

...

/*get_unmapped_area is invoked to find a suitable place for a new mapping in the mmaparea */

unsigned long (*get_unmapped_area) (struct file *filp,

unsigned long addr, unsigned long len,

unsigned long pgoff, unsigned long flags);

...

unsigned long mmap_base; /* base of mmap area */

unsigned long task_size; /* size of task vm space */

...

/*The start and end of the virtual address space area consumed by theexecutable code */

/*start_data and end_data mark the region that contains initialized

data*/

unsigned long start_code, end_code, start_data, end_data;


/*The start address of the heap is kept in start_brk, while brk denotes thecurrent end of the heap area */

unsigned long start_brk, brk, start_stack;


unsigned long arg_start, arg_end, env_start, env_end;

...

}


several configuration options that influence the layout of the virtual address space

If an architecture wants to choose between different possibilities for how the mmap area is arranged, it needs to set HAVE_ARCH_PICK_MMAP_LAYOUT and provide the function arch_

pick_mmap_layout.

When a new memory mapping is created, the kernel needs to find a suitable place for it unless

原创粉丝点击