5.6Segmentation and segmented paging
The idea
Segmentation divides a program into logical units of variable size. An address is (segment, offset), and the segment table gives base and limit.
Think of it like this: A report with chapters: you cite "chapter 3, page 5", and each chapter can be a different length.
Why it exists
It matches how programmers think (code, stack, data), and makes sharing and protection natural.
How it works
- Split the address into segment number s and offset d.
- Look up segment s: (base, limit). If s is invalid, trap.
- If d ≥ limit: trap (addressing error).
- Physical address = base + d.
Worked example: Segment 2 has base 4300 and limit 400
Offset 53 → 4353. Offset 400 or more traps because the limit is 400.
Now play with it
- →Enter segment 4, offset 1222: that exceeds the limit of 1000 and traps.
- →Compare paging and segmentation in the table.
| Segment | Base | Limit |
|---|---|---|
| 0 | 1400 | 1000 |
| 1 | 6300 | 400 |
| 2 | 4300 | 400 |
| 3 | 3200 | 1100 |
| 4 | 4700 | 1000 |
The limit check happens before the base is added. Segment 2 with offset 53 gives 4300 + 53 = 4353, but offset 400 would trap. Try segment 4 with offset 1222.
| Paging | Segmentation | |
|---|---|---|
| Unit size | fixed (page) | variable (segment) |
| Programmer sees it? | no | yes, logical units |
| Fragmentation | internal | external |
| Address | page number + offset | segment number + offset |
| Table entry | frame number | base and limit |
| Sharing / protection | per page | natural per segment |
Check yourself
Segmentation suffers from
Exam notes (the dense version)
Segmentation splits a program into logical units (code, stack, data) of variable size. A logical address is (segment number, offset); the segment table holds base and limit; the offset is checked against the limit (else a trap). It follows the programmer's view and eases sharing and protection, but suffers external fragmentation. Segmented paging (Intel style) pages each segment, combining the two: no external fragmentation and logical sharing.
Previous year questions: Memory Management (11)
PYQs are grouped by topic, so this is the full set for Memory Management; try the ones that match this subtopic. Open all 11 on the topic page.