← 🧱 Memory Management
Subtopic 6 of 6

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

  1. Split the address into segment number s and offset d.
  2. Look up segment s: (base, limit). If s is invalid, trap.
  3. If d ≥ limit: trap (addressing error).
  4. 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.
SegmentBaseLimit
014001000
16300400
24300400
332001100
447001000
Segment exists?yes
Offset < limit?yes
Physical address = base + d4353

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.

PagingSegmentation
Unit sizefixed (page)variable (segment)
Programmer sees it?noyes, logical units
Fragmentationinternalexternal
Addresspage number + offsetsegment number + offset
Table entryframe numberbase and limit
Sharing / protectionper pagenatural per segment

Check yourself

Segmentation suffers from

Remember: Segmentation: variable size, base + limit, external fragmentation. Paging: fixed size, internal fragmentation.
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.