Main Memory: Allocation, Linking & Segmentation

the segment table

Imagine a building directory in a lobby: 'Marketing — floor 3, occupies rooms 1 to 12; Accounting — floor 7, rooms 1 to 5.' Each department has an entry telling you where it starts and how big it is. To find 'Marketing room 4' you look up Marketing in the directory, confirm room 4 is within its 12 rooms, and go to floor 3, room 4. The segment table is exactly this directory for a program's segments.

Concretely, the segment table is a per-process table with one entry per segment. Each entry holds two numbers: the segment's base (its starting physical address) and its limit (its length). To translate a logical address given as (segment number s, offset d), the hardware uses s to index into the segment table, reads that entry's base and limit, checks that d is less than the limit (if not, it traps — a protection violation), and computes the physical address as base plus d. A segment-table base register tells the hardware where the table itself lives, and a segment-table length register bounds how many valid segments there are.

Why it matters: the segment table is the small piece of bookkeeping that makes segmentation work — it is where the base-and-limit idea generalizes from one block per process to one block per logical segment. Each entry also typically carries protection bits (read, write, execute) so the hardware can enforce, for example, that the code segment is never written to. When segmentation is combined with paging, each segment-table entry points instead to that segment's own page table, marrying the two schemes.

Segment table entry for segment 1: base = 6300, limit = 400, permissions = read/write. Logical (1, 500) -> the hardware checks 500 < 400, which fails, so it traps to the OS for an out-of-bounds access instead of returning a physical address.

One entry per segment: base, limit, and protection — checked on every access.

The segment table is per-process, so the OS must switch (or reload its base register for) the correct table on every context switch — just like base/limit registers, it is part of a process's protected state and only the kernel may set it.

Also called
segment descriptor table分段表