简体   繁体   中英

Page table size exercise from Tanenbaum's Modern Operating Systems

I decided to test my knowledge of internals of operating systems by solving problems from A. Tanenbaum's 'Modern Operating Systems'. And encountered the following problem:

Suppose that a machine has 48-bit virtual addresses and 32-bit physical addresses. If pages are 4 KB, how many entries are in the page table if it has only a single level?

As always since we have 48 bit virtual address space, we need to be able to map every memory address to physical one. So we have 2^48 addresses and each page is 4KB=2^12, so we need 2^36=2^(48-12) entries in a page table. So when we get 48 bit address we use higher 36 bits as an index to page table to find the number of page frame and then use lower 12 bits as an offset in a page frame.

Then I looked up in the solutions manual for the correct answer:

We need one entry for each page, or 2^24 = 16 × 1024 × 1024 entries, since there are 36 = 48 − 12 bits in the page number field.

I can not understand the reasoning behind the correct answer, is it indeed correct or am I missing something ?

You are absolutely right. If you have 48-bit virtual address and 4KB pages, you need at least 12 bits to choose the right byte in the page. So you have 2^48-2^12 = 2^36 entries in your page table to translate virtual address to physical. (Some of them would be on your disk).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM