Paging
Non-contiguous allocation: logical memory is cut into fixed-size pages, physical memory into equal-size frames, and a page table maps one to the other. External fragmentation disappears.
Logical Address
|
+------+--------+
| Page | Offset |
+------+--------+
|
Page Table
|
Frame Number
|
+-------+--------+
| Frame | Offset |
+-------+--------+
|
Physical AddressReal-world analogy: Book chapters in a shared shelf
Number of pages
8
Number of frames
16
Page number
3
Offset
428
Logical address
3500
Page #
3
Offset
428
Page table entry
invalid ✗
Physical address
Addressing error / page not in memory
Live page table (editable)
| Page No. | Frame No. | Valid |
|---|---|---|
| 0 | ✓ | |
| 1 | ✓ | |
| 2 | ✓ | |
| 3 | ✗ | |
| 4 | ✓ | |
| 5 | ✓ | |
| 6 | ✓ | |
| 7 | ✓ |
Step 1 · CPU emits the logical address
The process refers to a byte inside its own address space. The hardware treats this number as two parts.
Step 2 · Split into page number and offset
Page number = logical address ÷ page size, offset = logical address mod page size. The offset never changes during translation.
Step 3 · Look up the page table
The page number indexes the page table. If the valid bit is 0 the access traps (page fault / protection violation); otherwise we read the frame number.
Step 4 · Build the physical address
Physical address = frame number × page size + offset. The byte is fetched from that location in RAM.
Page size = 1 KB (1024 bytes). Logical address = 3500. The page table says page 3 → frame 7. Find the page number, offset and physical address.
1. What kind of fragmentation does paging still suffer from?
2. The offset part of a logical address is…
3. With page size 2 KB, how many pages does a 9 KB process need?