A system has 4 KB pages. Translate logical address 20000 if page 4 is stored in frame 9.
20000 = 4 x 4096 + 3616, so page number 4 and offset 3616. Frame 9 starts at 9 x 4096 = 36864, so the physical address is 36864 + 3616 = 40480.
Explain it simply
Paging splits a logical address into a page number and an offset within that page. The page table maps the page number to a frame number. The offset is copied unchanged, because pages and frames are the same size.
- Page number = address / page size (integer division)
- Offset = address mod page size
- Physical address = frame number x page size + offset
Example
Page size = 4 KB = 4096 bytes. Logical address = 20000.
- Page number = 20000 / 4096 = 4 (since 4 x 4096 = 16384 and 5 x 4096 = 20480 is too big).
- Offset = 20000 - 16384 = 3616.
- The page table says page 4 is in frame 9.
- Frame 9 starts at 9 x 4096 = 36864.
- Physical address = 36864 + 3616 = 40480.
In binary terms, 4096 = 2^12, so the lowest 12 bits of the address are the offset and the remaining high bits are the page number. Hardware does not divide; it just splits the bits.
Check: 4 x 4096 + 3616 = 16384 + 3616 = 20000, which matches the original address.
What to say in the interview
"With 4 KB pages, 20000 is page 4, offset 3616. Looking up page 4 gives frame 9, so physical = 9 x 4096 + 3616 = 40480. The offset never changes; only the page number is replaced by the frame number."
Common mistakes
- Multiplying the page number by the page size instead of the frame number.