So I have page sizes of 4kb
, 32
bit address CPU and an implemented 2-level page table.
I want to store 1081 pages, so I need:
1024
entries in the 2-nd level page-table57
entries in another 2-nd level page table2
entries.Now, do I need to store in memory the full size of these page table or just what they occupy?
4bytes * 2 + 4bytes * 1024 + 4bytes * 57
1 * 4bytes * 1024 + 2 * 4bytes * 1024
Any hint?
You would need 3 pages (or 12K) for your page table - one for the top level page, and two 2nd level pages. Allocating just the space that is currently needed would be more complicated and likely slower than the alternative.
Check out Prof. Levy's slides for some nice pictures on two level paging.