OS & Hardware
With a 4 KB page size, how many virtual address bits represent the position within a page (the offset)?
- A4 bits
- B12 bits
- C22 bits
Show answer and explanation
Answer: B. 12 bits
4 KB = 4,096 bytes = 2¹² bytes, so 12 bits are needed to distinguish each byte within a page. The low 12 bits of the virtual address pass straight through to the physical address as the in-page position, while the upper bits form the page number translated by page tables and the TLB. 4 bits is a slip prompted by the "4" in 4 KB, and 22 bits corresponds to 4 MB pages. The fact that the low 12 bits are not translated is also exploited in cache design.
- A. 4 bits can distinguish only 16 bytes.
- B. Correct. 4,096 = 2¹², so 12 bits.
- C. 22 bits corresponds to 4 MB pages.