Scheduler

A Scheduler is a component of the operating system that decides which process or thread gets access to the CPU and for how long.

Since the CPU can execute only one instruction per core at a time, the scheduler manages task switching between programs.

How it works

When multiple processes are running, they all compete for CPU time.

The scheduler:

  1. Selects the next process or thread
  2. Assigns CPU time (called a time slice or quantum)
  3. Switches between tasks

This switching is called context switching. 

The goal is to ensure that the system remains responsive and efficient.

Context Switching

Context switching happens when the CPU stops executing one task and starts another.

The system saves the current state (registers, memory info) of the running process and loads the state of the next one.

Although fast, context switching has a small performance cost.

 

Types of Scheduling

1. Preemptive Scheduling

The operating system can interrupt a running process to give CPU time to another task.

This improves responsiveness and is used in most modern systems.

 

2. Non-preemptive Scheduling

A process keeps the CPU until it finishes or voluntarily releases it.

This method is simpler but less flexible.

 

Common Scheduling Algorithms

Different systems use different strategies:

  • First Come, First Served (FCFS) – tasks are executed in arrival order
  • Round Robin – each task gets equal time slices
  • Priority Scheduling – tasks with higher priority run first

Modern operating systems often combine multiple algorithms.

Why it is important

  • Enables multitasking
  • Keeps the system responsive
  • Distributes CPU time fairly
  • Improves performance efficiency

Without a scheduler, programs would not share CPU resources properly.

Multi-core systems

On modern CPUs with multiple cores, the scheduler also decides:

  • Which core runs which task
  • How to balance system load

This improves overall performance.

A simple example

Imagine several people waiting to speak in a meeting. The scheduler acts like a moderator, giving each person time to talk so the discussion remains organized.

Related terms

Source

Information simplified from the Wikipedia article “Scheduling (computing)”.

Nach oben scrollen