Segmentation and Hybrid Memory Management in OS: Address Translation with Worked Examples

Learn how pure segmentation and segmented paging translate logical addresses. Follow two complete worked examples, see where faults occur, and avoid common exam traps.

KnowledgeGate Team

Exam prep & CS education

Updated 24 Nov 20265 min read
Segmentation and Hybrid Memory Management in OS: Address Translation with Worked Examples

In pure segmentation, a logical address contains a segment number and an offset. In hybrid segmentation with paging, a page number enters the address and the processor may need two table lookups before it reaches data. That extra field is where many otherwise sound solutions go wrong. Bounds and protection checks determine whether an address is valid before physical translation, and fragmentation differs between pure segmentation and hybrid segmentation with paging.

Segmentation in OS: the logical view and the segment table

A segment is a variable-length logical unit such as code, data, stack or a procedure. Its address is <segment number, offset>. The segment number selects an entry containing a physical base, a limit and protection bits. The processor checks the offset before adding it to the base.

This model follows program structure. Code can be read-only, data can be read-write, and segments can grow or be shared separately. Logical adjacency does not require physical adjacency.

Memory management sits inside the wider Operating Systems syllabus under CS Fundamentals. Addresses are byte-addressed, numbering starts at zero, and a segment limit stores a length, so 0 <= offset < limit.

Pure segmentation worked example: base, limit and a fault

Consider this segment table. Every base and limit is in bytes.

Segment

Base

Limit

Protection

Occupied physical range

S0

12,000

800

R-X

12,000-12,799

S1

4,000

1,200

R-W

4,000-5,199

S2

20,000

500

R-W

20,000-20,499

Logical order S0, S1, S2 does not determine physical order.

For logical address <0,750>, select S0 and test the offset: 750 < 800, so it is valid. The physical address is 12,000 + 750 = 12,750. S0 is marked R-X, so a read or instruction fetch is permitted, but a write is not.

For <1,1199>, the check 1,199 < 1,200 passes. This is the final legal byte of S1, and it maps to 4,000 + 1,199 = 5,199.

Now test <2,500>. The condition 500 < 500 is false, so the processor raises a segmentation or bounds fault. It must not add the base after this failed check. By contrast, <2,499> is valid and maps to 20,000 + 499 = 20,499.

Pure segmentation: offset 750 in S0 passes 750 < 800 and maps to physical byte 12,750, while offset 500 in S2 fails its limit check.

Paging, segmentation and the hybrid model are not interchangeable

Compare their address structure and allocation.

Model

Logical address fields

Allocation unit

Programmer-visible grouping

Fragmentation

Pure segmentation

<segment, offset>

Variable-sized segment

Yes, by logical segment

External fragmentation

Paging

<page, offset>

Fixed-size page and frame

No segment grouping

Possible internal waste in the final page

Hybrid segmented paging

<segment, page, offset>

Fixed-size pages within each segment

Yes, segments remain visible

Possible internal waste in each segment's final page

The hybrid model keeps segments but pages each one, so a whole segment needs no single contiguous physical hole. Memory Management in OS: Paging & Segmentation gives the broader comparison. The hybrid lookup path uses a segment table followed by a local page table.

Hybrid segmentation with paging: translate one 16-bit address

Hybrid segmentation translates segment 2, page 3, offset 700 to physical address 11,964 and rejects page 5.

A 16-bit logical address is split into 2 segment bits | 4 page bits | 10 offset bits. Thus, page size is 2^10 = 1,024 bytes = 1 KiB.

S2 has PTBR2 = 8,192, length 5 pages, and R-W permission. Its legal local pages are 0-4. Each PTE is 4 bytes; P3 is valid and holds frame 11.

Translate 10 0011 1010111100 step by step:

  1. 10 in binary is segment 2.

  2. 0011 in binary is page 3.

  3. 1010111100 in binary is offset 700.

  4. Check the segment-local page bound: 3 < 5, so P3 exists.

  5. Locate P3 at 8,192 + 3 x 4 = 8,204.

  6. P3 supplies frame 11. The physical address is 11 x 1,024 + 700 = 11,264 + 700 = 11,964.

  7. The offset also passes 0 <= 700 < 1,024.

The page number 3 is local to S2, not a system-wide page number.

Now test 10 0101 0001100100, or <segment 2, page 5, offset 100>. Offset 100 fits a page, but 5 < 5 is false. The address faults before any P5 lookup.

Protection, sharing, fragmentation and TLB cost in the hybrid scheme

A segment-table entry can protect a complete logical segment. PTEs may carry valid, dirty, referenced and page-level protection bits. Two processes can map a shared read-only code segment to the same frames while mapping private data and stacks elsewhere. These details depend on the implementation.

Pure segmentation leaves external holes because each variable-sized segment needs one contiguous region. Paging removes that requirement, but a segment's final page can still contain unused bytes. Hybrid paging does not eliminate all fragmentation.

In a simplified no-page-fault model where the TLB caches the complete <segment, page> to frame translation, let T be lookup time, M be one memory-access time and h be the hit ratio. A hit costs T + M. A miss reads the segment table, local page table and data, so it costs T + 3M. Therefore EMAT = h(T + M) + (1 - h)(T + 3M). The extra 2M on a miss belongs to this two-table hybrid path. Page Table Size and EMAT Numericals for GATE covers flat and multilevel table sizing and other timing models.

Segmentation and hybrid memory management traps

Match each wrong move to the correct check:

  • Accept offset 500 because S2 has limit 500 → legal offsets are 0-499, so <2,500> faults.

  • Add the base before checking the limit → validate the offset first.

  • Treat page 3 as physical frame 3 → use P3 to obtain frame 11.

  • Use PTBR2 + 3 as the PTE address → multiply the index by the 4-byte PTE size, giving 8,204.

  • Reject page 4 in a five-page segment → zero-based local pages are 0-4.

  • Accept page 5 because offset 100 fits → both page-within-segment and offset-within-page checks must pass.

Segments are variable-length logical units, not fixed-size frames. Hybrid paging can still waste space in a segment's final page, although the complete segment needs no contiguous physical hole.

How exams test segmentation and hybrid address translation

Stable question forms ask you to translate <segment, offset>, find the first invalid address, decode fields, derive page size, calculate a PTE address, or map <segment, page, offset> to a physical byte. Other forms count accesses under stated TLB assumptions, test protection, or distinguish internal from external fragmentation.

Write every assumption. Answers change if limit means maximum offset, numbering starts at one, a table is cached, or a TLB miss uses different accesses. Virtual Memory & Demand Paging MCQs (GATE OS) offers adjacent practice, not an official paper pattern.

Segmentation and hybrid memory management: the short version

Remember: pure segmentation = select segment -> check offset < limit -> base + offset; hybrid = select segment -> check page < segment length -> read local PTE -> frame x page size + offset. The results are <0,750> -> 12,750 and <S2,P3,700> -> 11,964.

Redraw both translation paths and explain why <2,500> and <S2,P5,100> fail at different checks. For broader structured GATE CS preparation, GATE Guidance by Sanchit Sir is an optional route.

Go deeper with the full courseOperating System

Keep learning

Discussion