---
title: "Virtual memory management; thrashing"
subject: "Operating System"
chapter: 4
key: "semester_6/operating_system:virtual-memory-thrashing"
source: https://www.bctengineer.com/q/semester_6/operating_system/virtual-memory-thrashing
site: BCT Engineering
---

# Virtual memory management; thrashing

Operating System · Chapter 4: Memory Management

- Asked in: year not given
- Video: [Virtual Memory Explained (including Paging)](https://www.youtube.com/watch?v=fGP6VHxqkIM) — BitLemon
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/virtual-memory-thrashing
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-4

## Question

What do you mean by virtual memory management? Explain about thrashing.

## Short answer

Virtual memory lets processes run with partial address space in RAM using demand paging. Thrashing is a state where insufficient frames cause constant page faults, collapsing CPU utilization; it is prevented by working-set model or page-fault frequency control.

## Answer

#### Virtual memory management
**Virtual memory** is a technique that lets a process run even when only part of it is in main memory. The logical (virtual) address space can be much larger than physical memory; the OS keeps the complete program on disk (swap area) and brings pages into memory when needed. The programmer sees a large, contiguous memory.

How it works (demand paging):
1. The virtual address space is divided into pages; physical memory into frames.
2. The MMU translates virtual to physical addresses using the page table (with a TLB cache).
3. A reference to a page not in memory causes a **page fault**; the OS loads the page from disk, using a page replacement algorithm (FIFO, LRU, optimal, clock) if no frame is free.
4. Management issues: page size, allocation of frames, replacement policy, working set, and load control.

Benefits: programs bigger than RAM can run, more processes can be in memory (higher CPU utilization), less I/O at start, memory protection and sharing. Cost: page-fault overhead; if faults are frequent the system slows down.

#### Thrashing
**Thrashing** is a state in which the system spends most of its time moving pages between disk and memory instead of executing processes. A process whose allocated frames are fewer than its working set faults continually; CPU utilization falls; the scheduler, seeing low utilization, admits more processes, and the faulting increases further.

```text
 CPU
 util |      ____
      |    /      \
      |   /        \____ thrashing
      |__/_________________
              degree of multiprogramming
```
Prevention/control:
- **Working-set model:** give each process enough frames for its working set; suspend a process if total demand exceeds memory.
- **Page-fault frequency (PFF):** add frames if the fault rate is above an upper limit, remove if below a lower limit.
- Use local replacement and reduce the degree of multiprogramming.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does virtual memory allow?
   A. A process to run with only part of it in memory, address space larger than RAM
   B. Only programs smaller than RAM
   C. Removing the page table
   D. Running without disk
   Answer: A. The full program stays on disk and pages are brought in on demand. (Key point: Virtual memory idea)

2. Which sequence describes thrashing?
   A. Frames < working set, constant faults, low CPU use, more processes admitted, more faulting
   B. Frames > working set, few faults, high CPU
   C. Disk is idle, CPU is idle
   D. TLB hits increase
   Answer: A. The loop of faults and added processes degrades the system further. (Key point: Thrashing feedback)

3. How does page-fault-frequency control work?
   A. Add frames if fault rate exceeds an upper limit, remove if below a lower limit
   B. Remove frames when faults are high
   C. Fix frames forever
   D. Raise page size
   Answer: A. PFF keeps the fault rate between two bounds by adjusting frames. (Key point: PFF)

## Related in Operating System

- [File system vs virtual memory; contiguous allocation](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afs-vs-virtual-memory-contiguous-tape) — Operating System, chapter 5
- [Page fault; virtual to physical address](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apage-fault-64k-virtual-32k-physical) — Operating System, chapter 4

## Related in other subjects

- [Space switch design with connection memory](https://www.bctengineer.com/question.md?key=semester_8%2Ftelecommunications%3Aspace-switch-connection-memory) — Telecommunications, chapter 4
- [Virtual destructor with example](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Avirtual-destructor) — Object Oriented Programming, chapter 7
- [Virtual short circuit and inverting integrator](https://www.bctengineer.com/question.md?key=semester_2%2Fbasic_electronics_engineering%3Avirtual-short-integrator) — Basic Electronics Engineering, chapter 4
- [Unique/non-unique decoding, memory mapped I/O](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aunique-nonunique-decoding-memory-mapped-io) — Microprocessor, chapter 4
