🧠 What is a Medium-Term Scheduler?

The Medium-Term Scheduler temporarily removes (swaps out) processes from main memory (RAM) and later brings them back (swaps in) to optimize memory usage and reduce CPU load.

In short, it’s the traffic manager for RAM — managing which processes stay in memory and which ones are paused and moved to disk.


🔁 Where Does It Fit?

[ Ready Queue ]
     ↑   ↓
[ Suspended Queue ] ←— (Swapped out by Medium-Term Scheduler)
  • It works between the Ready Queue and Suspended State.

  • Its job is to pause less-critical processes temporarily when memory is scarce.


🧩 Role of the Medium-Term Scheduler

RoleAction
📤 Swaps outRemoves a process from RAM → disk (Suspended)
📥 Swaps inBrings it back into RAM → Ready Queue
🧠 Memory ManagerHelps balance memory usage
🧹 Reduces MultiprogrammingTemporarily removes processes to free memory

📦 When Is It Triggered?

ConditionReason
🔴 Memory pressureToo many active processes for RAM to handle
⚖️ CPU overloadToo many active threads causing high context switching
🛑 Low-priority processesCan be swapped out to favor high-priority ones
↩️ A suspended process needs to be resumedIt gets swapped back in

⚙️ Real-World Analogy

Think of RAM as a small conference room.
When it gets full, the Medium-Term Scheduler asks some people to step outside for a bit so others can come in.
When there’s space, they’re invited back in.


🧪 Practical Use Case (Old Systems)

On older systems or low-RAM embedded devices:

  • 100+ processes may be active

  • RAM fits only 10–20

  • Medium-term scheduler rotates inactive processes to disk

In modern OSes, this is handled automatically by:

  • Virtual memory

  • Page replacement algorithms

  • Swap space


When a process is swapped out:

  • It’s not terminated

  • It’s put into a special state: Suspended (Ready) or Suspended (Blocked)

The Medium-Term Scheduler brings it back when:

  • Resources are available

  • It becomes relevant (e.g., a signal is received)


🧠 Interview-Ready Definition:

A Medium-Term Scheduler is a component of the OS that temporarily removes processes from main memory (swapping them to disk) to optimize memory usage and improve performance. It later resumes them by bringing them back into the ready queue.


🔗 Scheduler Comparison Table

SchedulerWhen It RunsWhat It Controls
Long-TermJob arrivalAdmission to system (Job → Ready)
Short-TermConstantlyCPU access (Ready → Running)
Medium-TermOccasionallyRAM usage (Ready ↔ Suspended)