Virtual memory, paging and segmentation
| English | Chinese | Pinyin |
|---|---|---|
| virtual address space | 虚拟地址空间 | xū nǐ dì zhǐ kōng jiān |
| paging | 分页 | fēn yè |
| segmentation | 分段 | fēn duàn |
| pages | 页 | yè |
| frames | 页框 | yè kuāng |
| page table | 页表 | yè biǎo |
| page fault | 缺页 | quē yè |
| swap file | 交换文件 | jiāo huàn wén jiàn |
| thrashing | 抖动 | dǒu dòng |
More memory than you really have
- 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.

Paging maps each page of logical memory to a frame of physical memory
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 抖动.

Segmentation maps variable-sized segments using a segment map table
What happens on a page fault
Step through a page fault. When the program touches a page that isn't in RAM, the OS quietly fetches it from disk and updates the page table — so the program sees more memory than physically exists.
In paging, memory is divided into:
Paging uses fixed-size pages and frames, linked by a page table. (Variable sizes are segmentation.)
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).
Match each memory-management term to its meaning.
Paging = fixed pages; segmentation = logical variable units; a page fault triggers a swap; too many faults = 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.

The OS shares the CPU, memory, disk and I/O between programs
Segmentation divides memory into variable-sized logical units (code, stack, heap), each with its own permissions, whereas paging uses fixed-size pages.
Segments match the program's logical structure; pages are uniform fixed-size blocks — some systems combine both.
You've got it
- 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)