OS & Hardware

With a 4 KB page size, how many virtual address bits represent the position within a page (the offset)?

  1. A4 bits
  2. B12 bits
  3. 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.
Practice this topic Back to topic

More OS & Hardware questions

  1. With 4 KB pages, which pair gives the page number and offset of the 32-bit virtual address 0x00403ABC?
  2. Which set of operating modes is defined by the RISC-V privileged architecture?
  3. When returning from an interrupt or exception handler, why is a dedicated return instruction (such as RISC-V's sret or mret) used instead of an ordinary function return?
  4. In a system requiring real-time behavior, which factor most increases interrupt latency, the time from an interrupt occurring until its handler starts?
  5. Which describes an NMI (non-maskable interrupt)?