Linux paging mechanism

Source: Internet
Author: User

1. The paging mechanism scrapped the segmented design, before we said in the blog that the excessive paragraph pattern, that is, each process has its own segment descriptor, recorded its own sections of the base. The paging mechanism actually discards this design pattern.

 2. The paging mechanism actually sets all the segment base addresses to 0, obviously if the paging mechanism is turned off then the linear address is the physical address if it is turned on can not be a direct correspondence.  3. Suppose we don't know what the paging mechanism does, guess what he has to do 1. Isolate the same address values for different processes, meaning that the same linear address is mapped to different physical addresses in different processes. 2. Implement the mapping of the linear address to the physical address.  4. Let's first talk about the design principle of the pagination. First of all, we put the linear address in the size of 4KB, but also the physical address in accordance with the size of 4kb to slice, is not thinking of disk chunking? Yes, we just have to put the block corresponding to the linear address to the physical address on the OK. There are a number of ways to do that. Let's just say one level of paging and two levels of paging.  5. One-level paging. We are now in memory to get a continuous space (page table), how big? The linear address has 4G (2^32), 4KB (2^12) segmentation can be divided into 2^20 units (page table entries), each unit has 32 bits. We get a linear address 32 bit, first get high 20 bits as this memory index, get a 32-bit unit, this 32 bits hold the base address of the physical address unit, interesting is because the linear address and physical address are 4kb to do the slicing so, separate these single heads address the lowest 12 bit is definitely 0, So our minimum 12 bit will not be saved as 0 but save some of the properties of the page such as permission God Horse. Linear address height 20 for the index to get the page table entry in the page table, the first 20 bits of the page table entry are then connected to the last 12 bits of the linear address to get a physical address, so that the last 12 bits of the linear address can be regarded as the offset address. Additional properties about the page are stored in the last 12 bits of the page table entry.  6. In order to make the process programming address independent, each process has its own page table, as mentioned in 3, then the page table base of each process how to get it, the old-fashioned register chant.  7. The first Level page table has two regrets, 1 page table in memory allocation must be continuous, otherwise how to index AH 2 each process of the page table must be really occupy 4M, must be fully allocated, the process is available.  8. In order to solve the two regrets people began to use level two paging. The linear address in the first-level paging is divided into two-part high 20-bit index page table entries to obtain the physical address base address, and a low 12-bit physical address offset address. In level two, the linear address is divided into 3 parts, high 10 bits, medium 10 bits, low 20 bits. The specific name is not much to say, because said will feel chaos. The high 10-bit is used to obtain an address in a 2^10 large table, which points to a memory table, the memory table is also 2^10 size, this memory table holds the physical address of the high 20 bits, connected to the low 12 of the linear address to obtain the physical address. You'llIt's not economical to ask for this, but the beauty is that when a table is indexed, the second table that the indexed cell points to will be allocated dynamically. The secondary table is obviously not allocated continuously in memory.   Reference  http://blog.163.com/wmk_2000_ren/blog/static/1388461922010228101742134/

Linux paging mechanism

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.