After the page is loaded, the OS:
Virtual Memory
Virtual memory larger than physical memory, demand paging and the valid–invalid bit, page faults and their handling, demand-paging performance, page replacement (FIFO and Belady’s anomaly, optimal, LRU) and thrashing.
How to read this page
Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.
All 30 slides
- 1 Slide 1
- 2 Outline of this lecture
- 3 Recall from previous chapter
- 4 Background
- 5 Virtual Memory That is Larger Than Physical Memory
- 6 Demand paging
- 7 Demand Paging
- 8 Transfer of a Paged Memory to Contiguous Disk Space
- 9 Valid-Invalid Bit
- 10 Page Table When Some Pages Are Not in MM
- 11 Page Fault
- 12 Steps in Handling a Page Fault
- 13 What happens if there is no free frame?
- 14 Performance of Demand Paging
- 15 Demand Paging Example
- 16 Basic Page Replacement
- 17 Need For Page Replacement
- 18 Basic Page Replacement (cont.)
- 19 Page Replacement
- 20 Page-Replacement Algorithms
- 21 Graph of Page Faults Versus The Number of Frames
- 22 First-In-First-Out (FIFO) Algorithm
- 23 FIFO Page Replacement
- 24 FIFO Illustrating Belady s Anomaly ’
- 25 Optimal Algorithm
- 26 Optimal Page Replacement
- 27 Least Recently Used (LRU) Algorithm
- 28 LRU Page Replacement
- 29 Thrashing
- 30 Thrashing
Steps in Handling a Page Fault
Notes
Handling: trap → check the reference → find a free frame → read the page from disk → update the table, set v → restart the instruction.
Exam angle
Performance of Demand Paging
Notes
EAT = (1 − p)·memory access + p·page-fault time. Even a tiny p hurts because a fault costs milliseconds.
Exam angle
Memory 200 ns, fault service 8 ms, p = 0.001. EAT ≈
- 0.999·200 + 0.001·8,000,000 ≈ 8,200 ns.
Basic Page Replacement
Notes
Page replacement: if no free frame, pick a victim; use a dirty (modify) bit so only modified pages are written back.
Page-Replacement Algorithms
Notes
Tip Practice string: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 with 3 frames → FIFO 15 faults, OPT 9, LRU 12.
FIFO Illustrating Belady s Anomaly ’
Notes
Belady’s anomaly: with FIFO, MORE frames can cause MORE page faults.
Exam angle
Belady’s anomaly occurs with:
Optimal Algorithm
Notes
Optimal (OPT/MIN): replace the page not used for the longest time in the future. Lowest fault rate but needs the future: used as a benchmark.
Exam angle
The optimal page-replacement algorithm can be implemented in a real OS.
- It needs future knowledge.
Least Recently Used (LRU) Algorithm
Notes
LRU: replace the page not used for the longest time in the past. Implemented with counters or a stack; no Belady’s anomaly.
Exam angle
Reference string 1 2 3 4 1 2 5 1 2 3 4 5 with 3 frames. Count FIFO page faults.
Compare with the model answer
9 faults (and 10 with 4 frames: Belady’s anomaly).
Thrashing
Notes
Thrashing: the process spends more time paging than executing because it has too few frames; CPU utilization drops.
Exam angle
Thrashing is when a process: