Segmentation Explained

Dividing Memory by Logical Meaning, Not Fixed Size

Paging (covered in the previous note) divides memory into fixed-size chunks with no regard for what they logically represent. Segmentation instead divides a process's memory according to its actual logical structure - separate segments for code, data, stack, and so on - each segment sized exactly to fit what it actually needs.

A process's logical view, divided into segments:
+------------+------------+-----------+
| Code       | Data       | Stack     |
| segment    | segment    | segment   |
+------------+------------+-----------+
(each segment can be a genuinely different size, matching its actual content)

The Segment Table: Similar in Spirit to a Page Table

Segment Table
Segment    Base (start address)   Limit (size)
Code       4000                   1500
Data       6200                   3000
Stack      9500                   2000

A segment table tracks where each segment actually lives in physical memory (its base address) and how large it is (its limit) - each memory access specifies both a segment number and an offset within that segment, and the hardware translates this into an actual physical address.

Paging vs Segmentation: A Direct Comparison

PagingSegmentation
Division basisFixed physical sizeLogical program structure
Segment/page sizesAll identicalCan vary, matching actual content
External fragmentationNoneCan still occur, since segments vary in size
Programmer/compiler visibilityInvisible to the processCan align meaningfully with logical program divisions

Combining Both: Segmentation With Paging

Many real systems use both together - dividing memory logically into segments first, then further dividing each individual segment into fixed-size pages - capturing paging's freedom from external fragmentation while still preserving segmentation's logical, meaningful structure.

Why Understanding Both Approaches Matters

Recognizing these as two genuinely different philosophies - dividing by fixed size versus dividing by logical meaning - makes it much easier to understand why modern systems often blend both ideas together rather than relying on either one in its pure, original form.

Written by Lorens Mishra

Software Engineer Notes Management System Administrator

Discussion

0 comments
Sign in to join the discussion.

No comments yet. Be the first to say something.