---
title: "Thrashing; page faults on 3 frames"
subject: "Operating System"
chapter: 4
key: "semester_6/operating_system:thrashing-page-faults-fifo-opt-lru-lfu"
source: https://www.bctengineer.com/q/semester_6/operating_system/thrashing-page-faults-fifo-opt-lru-lfu
site: BCT Engineering
---

# Thrashing; page faults on 3 frames

Operating System · Chapter 4: Memory Management

- Asked in: 2074 Bhadra, 2+8 marks
- Video: [Page Faults & Page Fault Handling in Operating Systems | Page Fault Numerical Example | Thrashing](https://www.youtube.com/watch?v=Nif2TZ5Cohw) — Simple Snippets
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/thrashing-page-faults-fifo-opt-lru-lfu
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-4

## Question

What is thrashing? Consider the following page-reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1. How many page faults would occur for the following page replacement algorithms, assuming 3 frames: a) FIFO b) Optimal c) LRU d) LFU

## Short answer

Thrashing is excessive paging when a process has too few frames for its working set. With three frames, FIFO causes 15 faults, Optimal 9, LRU 12, and LFU 13.

## Answer

#### Thrashing
**Thrashing** is excessive paging activity: a process spends more time swapping pages in and out than executing. It occurs when the number of frames given to a process is smaller than its working set, so a replaced page is needed again almost immediately. CPU utilization falls, the OS may add more processes (worsening it), and system throughput collapses. It is controlled with the working-set model, page-fault-frequency (PFF) control, local replacement and reducing the degree of multiprogramming.

#### Simulation (3 frames, initially empty)
Reference string (20 references): 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1. `*` = fault.

**a) FIFO**
```text
ref  7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
F1   7 7 7 2 2 2 2 4 4 4 0 0 0 0 0 0 0 7 7 7
F2   - 0 0 0 0 3 3 3 2 2 2 2 2 1 1 1 1 1 0 0
F3   - - 1 1 1 1 0 0 0 3 3 3 3 3 2 2 2 2 2 1
     * * * *   * * * * * *     * *     * * *
```
Faults = 15.

**b) Optimal**
```text
ref  7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
F1   7 7 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 7 7
F2   - 0 0 0 0 0 0 4 4 4 0 0 0 0 0 0 0 0 0 0
F3   - - 1 1 1 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1
     * * * *   *   *     *     *       *
```
Faults = 9.

**c) LRU**
```text
ref  7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
F1   7 7 7 2 2 2 2 4 4 4 0 0 0 1 1 1 1 1 1 1
F2   - 0 0 0 0 0 0 0 0 3 3 3 3 3 3 0 0 0 0 0
F3   - - 1 1 1 3 3 3 2 2 2 2 2 2 2 2 2 7 7 7
     * * * *   *   * * * *     *   *   *
```
Faults = 12.

**d) LFU** (least frequently used page is replaced; ties broken by oldest arrival)
```text
ref  7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
F1   7 7 7 2 2 2 2 4 4 3 3 3 3 3 3 3 3 3 3 3
F2   - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
F3   - - 1 1 1 3 3 3 2 2 2 2 2 1 2 2 1 7 7 1
     * * * *   *   * * *       * *   * *   *
```
Faults = 13.

| Algorithm | Page faults |
|---|---|
| FIFO | 15 |
| Optimal | 9 |
| LRU | 12 |
| LFU | 13 |

**Answer: FIFO = 15, Optimal = 9, LRU = 12, LFU = 13** (LFU depends on the tie-break rule).

## Check yourself

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

1. When does thrashing occur?
   A. When a process has more frames than its working set
   B. When the frames given to a process are fewer than its working set
   C. When the TLB hit ratio is 100%
   D. When the disk is empty
   Answer: B. Too few frames for the working set make replaced pages be needed again almost immediately. (Key point: Cause of thrashing)

2. Why does the OS often make thrashing worse?
   A. It sees low CPU utilization and admits more processes
   B. It halts all processes
   C. It increases page size
   D. It disables paging
   Answer: A. Low CPU utilization makes the scheduler add processes, which take frames and increase faulting. (Key point: Feedback worsening)

3. For 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 with 3 frames, how many faults does Optimal give, and how does it compare?
   A. 9, the lowest of FIFO 15, LRU 12, LFU 13
   B. 12, equal to LRU
   C. 15, equal to FIFO
   D. 13, the lowest
   Answer: A. Optimal gives 9 faults, fewer than LRU (12), LFU (13) and FIFO (15). (Key point: Fault counts)

4. Which is a recognised way to control thrashing?
   A. Page-fault-frequency control or the working-set model
   B. Increase the degree of multiprogramming
   C. Use global replacement only
   D. Shrink the page table
   Answer: A. PFF control and the working-set model, along with reducing multiprogramming, control thrashing. (Key point: Thrashing control)

## Related in Operating System

- [Page faults: FIFO, Optimal, LFU, LRU](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apage-faults-fifo-optimal-lfu-lru-5frames) — Operating System, chapter 4, asked 2×
- [Page faults with 3 frames: LRU, FIFO, OPT](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apage-fault-circumstances-lru-fifo-optimal) — Operating System, chapter 4, asked 2×
- [Page faults: LRU, FIFO, Optimum](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Apage-faults-lru-fifo-optimum) — Operating System, chapter 4
- [LRU algorithm; page faults on string](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Alru-page-faults-ref-string) — Operating System, chapter 4
- [Hits and faults: FIFO, LRU, Optimal](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Ahits-faults-fifo-lru-optimal-3frames) — Operating System, chapter 4
