Operating system page Storage method, page, page table, page table item

Source: Internet
Author: User

//
Operating system and computer principles are described in memory management page management, but I and many of the first time to learn paging, will be confused page table size and the relationship between page table item size, I carefully analyzed the post wrote this blog, only when learning and communication, personal understanding of the use, if the error or analysis is not rigorous, Please correct me.
According to the combination of words, graphs, I believe it is easier to read. //First, define a few concepts

Logical address: After the program is compiled, the generated target module is addressed from unit No. 0, which is called the relative address of the target module, which is the logical address.

Page: The block that divides the process, the corresponding size is called the page size.

Page Box: A block that divides memory.

Page and page boxes correspond to one by one, a page is placed in a page box, and (theoretically) the size of the page is equal to the size of the page box.

Page table: is a page and page box one by one corresponding to the relationship table. The "Store in memory" relational table is just an index that can be traced to a page and a page box based on the relational table.

//

//second, use examples to speak "example out now:" King's Examination operating system memory management part "

Known conditions: Logical address 32 bits, page size 4KB, page table item size 4B, by byte addressing.

Analysis: 1.

First

32

The virtual address of a bit can represent the process size should be 2^32b = 4GB (temporarily don't think page number p occupies how many bits, W accounted for how many bits)

2. (depending on the definition of the page and the definition of the page size) the process is paginated: 3. We already know that the number of pages is: 2^20 page. The confusion now lies in the problem of the page table item. the figure above shows several data on the page table: 20-bit, 12-bit, 32-bit, 2^20. One by one explained as follows "Please combine one data analysis with the above figure":

2^20: Because the page table is intended to correspond to page box one by one of the page, each page should have a page table entry in the page table: used to indicate a page number corresponding to a page box number (in-memory block number), it should be

There are 2^20 items. "There shouldn't be a problem, it's like a class with 50 classmates, everyone should have an address."

20-bit: it is already obvious that you need to represent a 2^20 page table entry that requires at least 20 bits of address. Why only 20-bit instead of 21-bit, 22-bit, I have not thought of this problem, it is temporarily set to just take 20 bits.

32 bit: The known condition tells the page table item size is 4B, then naturally should be 32 bit.

12 bits: 32 bits-20 bits = 12 bits. Why the page box number address is 12-bit, can only represent 2^12 page box, is smaller than 2^20 pages, because not every page of the process to be transferred into memory. In fact, 32-bit, 12-bit, 20-bit this three data still have a certain basis, in the two-level pagination will find "Oh, originally just good." Level two paging is not currently discussed here. 4. What data do we derive from the above analysis:

Logical address 32 bits, process size: 4GB.

Page: Size 4KB, Quantity: 2^20 page.

Page Table entry: 4B, Quantity: 2^20 item. So the page table needs 4b*2^20 = 4MB of Space Storage (this is the book says: Page table item size is the origin of 4MB) further, main memory page box size and page size is equal, also 4KB, so the page table in main memory needs to occupy 4MB/4KB = 1024 pages (because the page table is also in main memory, and main memory is divided by the page box.) This is really a waste of resources, so you need to create a level two page, the size of the 1 pages, the level two pages into main memory can be

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.