---
title: "TLB, thrashing; coalescing vs compaction"
subject: "Operating System"
chapter: 4
key: "semester_6/operating_system:tlb-thrashing-coalescing-compaction"
source: https://www.bctengineer.com/q/semester_6/operating_system/tlb-thrashing-coalescing-compaction
site: BCT Engineering
---

# TLB, thrashing; coalescing vs compaction

Operating System · Chapter 4: Memory Management

- Asked in: 2075 Baisakh, 2+2+2 marks
- Video: [Compaction vs Coalescing with example in Operating Systems](https://www.youtube.com/watch?v=bMgDPc3tdL8) — IT Hub by MDSR
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/operating_system/tlb-thrashing-coalescing-compaction
- Whole chapter: https://www.bctengineer.com/md/semester_6/operating_system/chapter-4

## Question

What is TLB and Thrashing? Write the differences between Coalescing and Compaction. Provide examples of both.

## Short answer

TLB is a fast cache for page-table entries; thrashing is excessive paging due to insufficient frames. Coalescing merges adjacent free holes without moving processes (e.g., 10K+15K become 25K), while compaction relocates processes to combine all free memory into one large block.

## Answer

#### TLB
The **Translation Lookaside Buffer** is a small, fast associative cache in the MMU that stores recently used page-number to frame-number translations. On a memory reference the page number is searched in the TLB in parallel: on a hit the frame number is obtained without reading the page table in memory; on a miss the page table is consulted and the entry is added to the TLB. It reduces the effective memory access time (a typical TLB has 16 to 512 entries and a hit ratio above 90%).

#### Thrashing
**Thrashing** means a process (or system) spends more time paging than executing, because it has too few frames for its working set. A page is replaced and then referenced again immediately, causing a continuous stream of page faults and low CPU utilization. Remedy: working-set model, page-fault-frequency control, or lowering the multiprogramming level.

#### Coalescing vs compaction
| Point | Coalescing | Compaction |
|---|---|---|
| Idea | Merge adjacent free holes | Move processes together to join all holes |
| Process movement | No | Yes |
| Cost | Low | High |
| Result | Larger hole where holes were adjacent | One single large hole |

**Example of coalescing:** a 10 K hole and an adjacent 15 K hole (a process between them just terminated) become one 25 K hole.

**Example of compaction:** memory = OS | P1 (20 K) | hole 10 K | P2 (30 K) | hole 15 K. Moving P2 down gives OS | P1 | P2 | one hole of 25 K, so a 25 K process can now be loaded.

## Check yourself

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

1. What happens on a TLB hit?
   A. The frame number is obtained without reading the page table in memory
   B. The page table is read first, then the TLB
   C. A page fault occurs
   D. The process is suspended
   Answer: A. The TLB caches page-to-frame translations, so a hit avoids the memory access to the page table. (Key point: TLB function)

2. Why does a thrashing process show low CPU utilization?
   A. It has too few frames for its working set and spends more time paging than executing
   B. It has too many frames
   C. It has no page table
   D. TLB is disabled
   Answer: A. Continuous page faults mean the time goes to paging, not execution. (Key point: Thrashing)

3. What is the key difference between coalescing and compaction?
   A. Coalescing moves processes; compaction does not
   B. Compaction moves processes to join all holes; coalescing merges only adjacent holes without moving
   C. Both move processes
   D. Neither changes hole sizes
   Answer: B. Coalescing merges adjacent holes with no movement and low cost; compaction moves processes and costs more. (Key point: Coalescing vs compaction)

4. With OS | P1 (20K) | hole 10K | P2 (30K) | hole 15K, what does moving P2 down achieve?
   A. Two holes of 10K and 15K remain
   B. One 25K hole so a 25K process can load
   C. The holes shrink to 5K
   D. P1 is deleted
   Answer: B. Compaction joins the 10K and 15K holes into a single 25K hole. (Key point: Compaction example)

## Related in Operating System

- [Compaction vs coalescing; paging; TLB](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Acompaction-coalescing-paging-tlb) — Operating System, chapter 4
- [Compaction vs coalescing; paging mapping](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Acompaction-coalescing-paging) — Operating System, chapter 4
