开发者

How is the logical address divided in case of multilevel page table

Hi,


In order to use large size page table hierarichal paging is done .
In case of two level page table scheme . for :
logical address space - 32bit - 2^32 
page size - 4kb i.e 2^12

In one level : 

page number - 20bit  calculated as (32 - 12)
page offset - 12 bit 

Now, In two level :

again, page number -  20bit is split into pagenumber(second level) and page offset .also
the address space is (2^20)

considering again page size of 4kb - (2^12)
so page number(second level ) should be calculated as : (20 - 12 ) - 8bits
and page offset : 12 bits.

But, It is mentioned that page number is divided evenly :

i.e page number p1 - 10 bits
    page number p2开发者_StackOverflow中文版 - 10 bits
    page offset d - 12bits.

Why is the second level pagenumber divided evenly ? Is it that this division done
arbitarily according the requirement ? Is there no specific method for dividing as in case of single-level page table ?    

Any help will be valuable . Thanks, Tazim


With 4 KB pages, the last 12 bits are the offset into the page. That leaves 20 bits for a 32 bit address. These 20 bits are used as an index into the page tables, not an offset. By splitting them evenly between the 2 levels, the tables are both the same size. The first table specifies the address of the second table, and the second table specifies the physical address of the page. 10 bits for each index means 1024 entries in each table. This is very convenient because it means each table is exactly 1 page when using 32 bit entries.

Example: Take the address 0x00FF1234. The binary representation of this address is 00000000111111110001001000110100. By splitting this up, we get 0000000011 1111110001 001000110100, or 0x3 0x3F1 0x234. So item 3 in the first level table gives the address of the second level table, item 0x3F1 in the second table gives the address of the page used, and the address is 0x234 bytes into that page.


This blog series has a very indepth set of examples for how the page table works, how to convert virtual<->physical addresses and such.

Here's an exerpt;

How is the logical address divided in case of multilevel page table


It is obvious that the offset takes 12 bits. When the size of each entry is 4bytes, you get result that 10 bits for outer page table and 10 bits for inner table table. The calculation is as following:

(2^20 entries × 4 bytes/entry)/4k bytes = 2^10 --> outer page table should have 10 bits (space taken by page table)/frame(or page)size = no. of inner page tables

4k bytes/4 bytes = 2^10 --> inner page table should have 10 bits (size of pages in page table)/size of entries = no. frames

That how it gets 10 bits and 10 bits evenly. For different situation, it is not necessary to have even distribution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜