Linux Virtual memory Management __linux

Source: Internet
Author: User

virtual Memory refers to the amount of memory that a computer presents that is much larger than it actually has. So it allows programmers to compile and run a much larger program than the actual system has. This allows many large projects to be implemented on systems with limited memory resources. A proper analogy: you don't need a long track to get a train from Shanghai to Beijing. You only need a long enough track (say 3 km) to complete the task. The way to do this is to put the back rails immediately ahead of the train, as long as your operation is fast enough to meet the requirements, the train can be like in a complete track of the operation. This is the task that virtual memory management needs to accomplish. In the Linux 0.11 kernel, each program (process) is divided into a total capacity of 64MB of virtual memory space. Therefore, the logical address range of the program is 0x0000000 to 0x4000000.

The Linux system has a segmented and paging approach to memory management, maintained with the struct page array mem_map for each page usage. There is user space and kernel space in the Linux system, and these two spaces are for the linear address. The linear address of kernel space is generally 3g~4g, and the address of user space is 0~3g.

When the program is running in the user state, only access to 0~3g user space, while running in the kernel state can access the 3~4G kernel space. If the linear address of kernel space is one-to-one mapping with the physical address, it is obvious that the kernel can only access 1G of memory space. This design is not allowed because the kernel should have access to the entire memory space. So the designer of Linux puts forward another concept, namely high-end memory and low-end memory. Low-end memory is the 896M linear address space starting from 3G, which maps directly to the 0~896m of the physical address. And then some of the linear addresses are dynamic mappings, mapped to the part after the physical memory 896M.

In order to map a linear address to a physical address, a page catalog table and a page table are required. In linux2.4, each process has its own page Catalog table and page table. When a new process is created and a new page table is created, the 0~768 entry of the process is emptied (each page directory corresponds to 4 m memory, 768 is exactly 0~3g), and the 768~1024 item of the kernel process is copied to the current process, which enables all processes to share the kernel address space. But this does not mean that all processes have access to the kernel address space, because the 3~4g linear address is generated only when a interrupt occurs or a system call is required to run into the kernel state.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.