The difference between the Linux 0.12 kernel and the modern kernel in memory management

Source: Internet
Author: User

0.12 kernel memory management is relatively simple rough, the kernel only uses a page directory, can only map 4G of linear space, so each process of virtual space (logical space) can only give 64M, up to 64 processes; Each process has a corresponding task number NR, when a process needs to allocate process space, The linear start address of the process space can be obtained only by multiplying nr by 64M. The process's code snippet, data segment Descriptor's base Address field is then set to (Nr x 64M), and the process can be assigned a page catalog entry and a page catalog table to host the mapping relationship.

Then, if the process wants to access an address in its own space, it will first use the base address and the 32-bit offset address (logical address) of the program to synthesize linear addresses, the synthesized linear address must be (segment base) ~ (segment base + section limit) between, that is (nr x 64M ~ nr x 64m+64m) between. Then use this linear address to follow: "Page directory Items-page table-page Table table entries" in order to find the corresponding page table entries, also found the physical address, you can actually access the data.


But in the modern kernel, there are many differences in memory management.
First, the linear address space does not change, and the 32-bit CPU can address 4G linear space. This is the only one.
But how does each process have its own independent 4G virtual space? In fact, each process gives it its own page directory, so that each process can have 4G of virtual space (logical space).

Note: The 0.12 kernel two processes each have a different linear address, because each process occupies a distinct area of linear space. But in the modern kernel, A and b two processes may synthesize the same linear address, because each process has 4G of virtual space, which means that the virtual space and the linear space are equivalent. However, because the page and page tables of the two processes are different, the two processes map to different physical addresses by mapping the linear addresses of the respective values that are synthesized. That is, the mapping between the linear space and the physical space is different. In other words, in the modern kernel, virtual space (logical space) and linear space are almost a concept, and the following are not distinguished.


For example, even if a and B processes simultaneously access the 0x0804800 address of their linear space, the segmented paging address transformation mechanism maps the linear address of the 0x0804800 to a different physical address. And this process, the process itself is invisible, A and b all think they have successfully visited 0x0804800 this address, but in fact, they are accessing the linear space in the "value of equal" linear address, and eventually the two "number of equal" linear address will be mapped to different physical memory address. This enables process isolation.
Each process has 4G of linear space (virtual space), the linear space of the process is isolated from each other, and each process is working in its own world.


The above is said from the operating system principle point of view, put on the specific Linux operating system will be a little different. Because the Linux kernel specifies that each process has a 4G linear space, they are not free to use all 4 G. 0-3G is a user space, it is indeed free to use, but the 3g-4g between the kernel space, can not be used arbitrarily. Therefore, the above theory can be perfected as, each process has a size of 4G linear space, this 4G linear space is divided into two parts:

Size of 3G user space, each process under the "Privilege Level 3" can be freely used independently, the space of each process is completely independent of each other, is pointing to the physical memory in different locations.

The size of 1G kernel space, each process under the "privilege Level 0" can use this space, the space of each process is not independent, is pointing to the same physical memory location. This means that all processes are shared.


This article is from the "Linux Kernel Developer" blog, so be sure to keep this source http://mirage1993.blog.51cto.com/2709744/1726295

The difference between the Linux 0.12 kernel and the modern kernel in memory management

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.