How does paging translate a logical address into a physical address?
MediumConceptVirtual Memory & Paging
Answer
In paging, a logical address is split into a page number (p), taken from the high-order bits, and an offset (d), taken from the low-order bits. The MMU looks up page p in the process's page table to find the frame number f, and the physical address is f × page size + d.
- The page size is a power of 2 (commonly 4 KB), so splitting just means taking bits: with 4 KB pages, the lowest 12 bits are the offset, because 2^12 = 4096.
- Each process has its own page table; on a context switch, the OS loads its location into a page-table base register.
- Each page-table entry also stores flag bits: valid, dirty (modified), referenced and protection (read, write, execute).
- Without a TLB, every memory access needs two RAM accesses: one to read the page table and one for the data itself.
Example: the page size is 1 KB (1024 bytes), and the page table maps page 0 → frame 3, page 1 → frame 7 and page 2 → frame 5. For logical address 2500:
p = 2500 div 1024 = 2, and d = 2500 mod 1024 = 2500 − 2048 = 452.
Page 2 maps to frame 5, so the physical address = 5 × 1024 + 452 = 5120 + 452 = 5572.