Operating Systems Reference/Memory Virtualization

Virtual Address Spaces

Each process sees addresses 0..MAX as its own — code, heap, stack, and shared libraries mapped independently; why one process cannot read another's memory without explicit sharing.

2/5Overview: 20m

The illusion of private memory

Each process sees a contiguous virtual address range (typically 0 to 2⁴⁷–1 on 64-bit Linux user space). Code, heap, stack, mmap regions, and shared libraries occupy separate virtual ranges. Process A at virtual address 0x1000 maps to completely different physical frames than process B at 0x1000 — isolation by design.

Typical layout (conceptual)

RegionGrowsContents
Text (code)FixedRead-only executable instructions
Data/BSSFixedInitialized and zero-initialized globals
Heap↑ upwardmalloc allocations
mmap arenasVariableShared libs, file mappings, large allocs
Stack↓ downwardLocal variables, return addresses

ASLR randomizes base addresses to frustrate exploit chains — /proc/<pid>/maps shows the actual layout.

Why virtual addresses exist

  • Isolation — processes cannot read each other's memory without mmap(MAP_SHARED) or ptrace.
  • Simpler linking — every binary can assume it loads at the same virtual base.
  • Sparse address spaces — reserve 1 TB virtual for a memory-mapped file without committing physical RAM.
  • Overcommit — allocate virtual pages now, back with physical frames on first touch.

Senior-level signal

A segfault is the kernel killing your process for an invalid virtual access — unmapped page, write to read-only, stack overflow into guard page. dmesg may show the faulting address; compare against /proc/<pid>/maps to distinguish null-pointer bugs from stack exhaustion.

Where this goes next

Paging & Page Tables explains the data structures that translate those virtual addresses into physical frames — and how page faults make demand paging work.

Further Reading

Hands-On Tasks (Optional)

Low-setup exercises on your local machine. No autograding — the goal is to build intuition, not pass a test.

  • Inspect a process memory map

    Pick a PID (`pgrep -l python` or any long-running process). On Linux: `cat /proc/<pid>/maps | head -20`. On macOS: `vmmap <pid> | head -30`. Identify heap, stack, and mapped libraries.

    15m