Virtual memory, paging and segmentation
Virtual memory
- Each process gets its own virtual address space — a clean, contiguous range of addresses.
- The OS maps it to physical RAM (and disk), which protects processes and lets memory exceed physical RAM.
- Two schemes: paging and segmentation.
Virtual address space
- Each process sees a simple, private space — it never touches another process's memory.
- The OS maps virtual addresses to physical ones, so the total memory can exceed the installed RAM.
- This isolation is also a key security boundary.
Practice
A benefit of virtual memory is that it:
Virtual memory gives each process a private space and lets the working set exceed installed RAM by using disk.
Paging
- The virtual space is split into fixed-size pages; physical memory into same-sized frames.
- A page table maps each page to a frame.
- If a needed page isn't in RAM — a page fault — the OS reads it from the swap file into a frame, evicting another page if RAM is full.
- Constant faulting (more swapping than work) is thrashing.
Practice
In paging, memory is divided into:
Paging uses fixed-size pages and frames, linked by a page table. (Variable sizes are segmentation.)
Practice
A page fault occurs when:
The accessed page isn't in a frame, so the OS fetches it from the swap file (evicting another page if needed).
Practice
Thrashing is when:
Too many page faults cause constant swapping, so little real work gets done — thrashing.
Segmentation
- Segmentation splits memory into variable-sized logical segments (code, stack, heap), each with its own permissions.
- Unlike paging's fixed pages, segments match the program's logical structure.
- Many systems combine both: paging within segments.
Practice
How does segmentation differ from paging?
Segments are variable-sized and match the program's logical structure, each with its own permissions; pages are fixed-size.
You've got it
Key idea
- virtual memory gives each process a private space, protects processes, and exceeds physical RAM
- paging = fixed-size pages → frames via a page table; a page fault loads from the swap file
- too much faulting → thrashing
- segmentation = variable-sized logical segments (code/stack/heap)