Translating addresses with segmentation

A process with code, heap and stack segments, following the Segmentation chapter of OSTEP. Its 16KB address space uses 14-bit virtual addresses: bits 13 and 12 name the segment and the other 12 bits are the offset. The segments are placed in 64KB of physical memory.

Or try

Use decimal, hex (0x…) or binary (0b…), from 0 to 16383.


  

Virtual address space

16KB. The top two bits pick one of four 4KB slots.

Virtual address

—

Segment table

Held in the MMU's segment registers.

SegmentBaseSizeGrows positive?Protection

Offset inside the segment's 4KB slot

01K2K3K4K
Inside the segmentOutside, so the access faults

Shown once the segment is known.

Physical memory

64KB. Each segment sits at its own base.

No physical address: the hardware raised a fault.

What the hardware runs

// SEG_MASK = 0x3000   SEG_SHIFT = 12
// OFFSET_MASK = 0xFFF  MAX_SEG_SIZE = 4KB

Translations

VirtualSegmentOffsetPhysical

Keyboard: ← → to step, Space to play or pause.