>_
EngineeringNotes
← Back to OS Internals
Chapter 06

Swapping & Switching

Understanding how OS manages overflow memory through Swapping and handles process transitions via Context Switching.

01

What is Swapping?

Swapping is a mechanism in which a process can be moved temporarily out of main memory (RAM) to secondary storage (Disk) to make memory available for other processes.

The Real-World Analogy

"Suppose we open multiple tabs in a browser. You can see all tabs open, but a few tabs open quickly while others take time because they were at Secondary Storage (Swap Space)."

Medium Term Scheduler (MTS)

Swapping is primarily managed by the MTS. It is done when the "Degree of Multiprogramming" increases beyond RAM capacity.

02

The Swapping Mechanism (Diagram)

RAM
MAIN MEMORY
READY QUEUE
P1P2P3
Swap OutRemove process from memory to
reduce degree of multiprogramming
Swap InBring back partially executed
process from disk to RAM
Controller
MTS Scheduler
HDD / SSD
SWAP SPACE
DISK POOL