Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 4.4: Segmentation

Memory organised as the programmer sees it — variable-size segments with base and limit — and how segmentation combines with paging.

Module 4 1 hour Theory CO4
← Before
4.3 Paging & TLB
Pages and frames
You are here
4.4 Segmentation
Module 4 · Memory and File Management
Next →
4.5 Virtual memory
Demand paging

Learning objectives

By the end of this session you should be able to:

  • Describe the programmer's view of memory that segmentation supports.
  • Translate (segment, offset) addresses using a segment table and detect traps.
  • Explain protection and sharing in segmentation.
  • Compare paging and segmentation, including fragmentation.
  • Explain segmentation with paging as in Intel IA-32.

Lecture notes

1. The programmer's view of memory

Programmers do not think of a program as a linear array of bytes, but as a collection of variable-sized logical units: main program, functions, global variables, stack, symbol table, arrays. Segmentation is a memory-management scheme that supports this view: the logical address space is a collection of segments, each with a name (number) and a length.

A logical address is a pair <segment-number s, offset d>. The C compiler, for example, might create separate segments for code, globals, heap, each thread's stack, and the standard library.

2. Segment table and translation

Each entry of the segment table has a base (starting physical address of the segment) and a limit (its length). The segment-table base register (STBR) points to the table; STLR holds the number of segments.

CPU issues (s, d).

If s ≥ STLR → trap (no such segment).

Look up entry s: if d ≥ limit → trap: addressing error (segmentation fault).

Physical address = base + d.

Worked example (Silberschatz)
SegmentLimitBase
010001400
14006300
24004300
311003200
410004700
  • (2, 53) → 53 < 400 → 4300 + 53 = 4353
  • (3, 852) → 852 < 1100 → 3200 + 852 = 4052
  • (0, 1222) → 1222 ≥ 1000 → trap

3. Protection and sharing

Because segments are meaningful units, protection fits naturally: the code segment can be marked read-only/execute, the data segment read–write, and an array can be bounds-checked by the hardware limit. Sharing is also natural — two processes share a library by having segment-table entries with the same base.

4. Paging vs segmentation

PagingSegmentation
Unit sizeFixed (page)Variable (segment)
Visible to programmer?NoYes — logical units
AddressSingle number split into (p, d)Explicit pair (s, d)
FragmentationInternal (last page)External (variable holes)
Table entryFrame numberBase and limit
Protection / sharingPer pagePer logical unit — more natural

5. Segmentation with paging

Segments still need contiguous memory, so external fragmentation returns. Combining both gets the best of each: each segment is itself paged. The logical address (s, d) is first turned into a linear address using the segment table, then the linear address is translated by paging. This is the classic Intel IA-32 design (segmentation unit → paging unit). In 64-bit x86-64, segmentation is essentially disabled (flat segments) and paging does the work.

logical (s, d)→segmentation unit→ linear address→paging unit→physical

VideoBytes

Segmentation

Video coming soon

Segmentation

Recorded by Dr. Krithika L.B. Slot m4-segmentation

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
Using the worked-example table, translate (1, 10), (4, 1100) and (3, 0).

(1,10) → 6310 · (4,1100) → trap (limit 1000) · (3,0) → 3200.

Which kind of fragmentation does segmentation suffer from?

External fragmentation, because segments have variable sizes.

Why is protection more natural with segmentation than with paging?

Segments correspond to logical units (code, data, stack) that need different protection; a page may mix different kinds of content.

What are STBR and STLR?

Segment-table base register (location of the segment table) and segment-table length register (number of segments).

Key takeaways

  • Segmentation: logical address = (segment, offset); physical = base + offset if offset < limit.
  • Natural protection and sharing; suffers external fragmentation.
  • Segmentation with paging (Intel IA-32) pages each segment.

Where this leads

So far a whole process had to be in memory to run. What if only the parts actually being used were loaded? That is virtual memory.

Continue to 4.5 — Virtual memory and demand paging →