Header Ads

Different Scheduling Algorithm, Which one to Used Where?

Scheduling algorithms determine which process or task gets the CPU next. The scheduler's goal is to optimize one or more of the following:

  • CPU utilization
  • Throughput
  • Response time
  • Waiting time
  • Turnaround time
  • Fairness
  • Meeting real-time deadlines

Comparison Overview

AlgorithmPreemptiveMain IdeaUsed In
FCFSNoFirst process to arrive runs firstSimple batch systems
SJFNo (or Yes as SRTF)Shortest job runs firstBatch processing
Round RobinYesEqual CPU time for allTime-sharing OS
Priority SchedulingYes/NoHighest-priority process firstRTOS, Embedded
Multilevel QueueYesSeparate queues for different classesGeneral-purpose OS
Multilevel Feedback QueueYesProcesses move between queuesModern desktop OS
EDFYesEarliest deadline firstHard real-time systems

1. FCFS (First Come First Serve)

Definition

The process that arrives first gets the CPU first.

It is the simplest scheduling algorithm.


Logic

Ready Queue

P1 → P2 → P3 → P4

Execution

CPU

P1

↓

P2

↓

P3

↓

P4

Example

ProcessArrivalBurst
P105
P213
P322

Execution

0-----5-----8----10

P1    P2    P3

Advantages

  • Very simple
  • No starvation
  • Easy implementation

Disadvantages

  • Convoy Effect
  • Long waiting time
  • Poor response time

Used In

  • Batch systems
  • Printer queues

2. SJF (Shortest Job First)

Definition

The process with the smallest CPU burst time executes first.


Example

ProcessBurst
P18
P24
P32
P41

Execution

P4

↓

P3

↓

P2

↓

P1

Advantages

  • Minimum average waiting time
  • Efficient for batch jobs

Disadvantages

  • Need to know burst time beforehand
  • Starvation of long jobs

Variant

Preemptive version:

Shortest Remaining Time First (SRTF)


3. Round Robin (RR)

Definition

Each process gets a fixed amount of CPU time called the Time Quantum.

If it doesn't finish, it goes to the end of the queue.


Example

Time Quantum = 2 ms

Queue

P1 P2 P3

Execution

P1

↓

P2

↓

P3

↓

P1

↓

P2

Advantages

  • Fair
  • Good response time
  • No starvation

Disadvantages

If quantum is too small:

  • Too many context switches

If quantum is too large:

  • Behaves like FCFS

Used In

  • Linux (historically for some scheduling classes)
  • Windows
  • Interactive systems

4. Priority Scheduling

Definition

The process with the highest priority executes first.


Example

ProcessPriority
Brake5
Engine4
Display2

Execution

Brake

↓

Engine

↓

Display

Types

Non-preemptive

Current process finishes first.

Preemptive

Higher-priority process immediately interrupts.


Advantages

  • Critical tasks run first
  • Excellent for RTOS

Disadvantages

Starvation of low-priority tasks.


Solution

Aging

Increase waiting process priority over time.


Used In

  • OSEK
  • AUTOSAR
  • FreeRTOS
  • VxWorks

5. Multilevel Queue Scheduling

Processes are permanently divided into different queues.

Example

System Queue

Interactive Queue

Batch Queue

Each queue has its own scheduling policy.

Example

System

↓

Round Robin

Interactive

↓

Priority

Batch

↓

FCFS

Example

Highest

System Queue

↓

Interactive Queue

↓

Batch Queue

Lowest

The scheduler first checks the highest-priority queue.


Advantages

  • Good separation
  • Efficient

Disadvantages

A process cannot move between queues.


Used In

Desktop operating systems.


6. Multilevel Feedback Queue (MLFQ)

Improvement over Multilevel Queue.

Processes can move between queues.


Example

Queue 1

High Priority
Quantum = 5

Queue 2

Quantum = 10

Queue 3

FCFS

Logic

Short jobs

Stay at top.

Long jobs

Move downward.


Example

P1

Queue 1

↓

Uses entire quantum

↓

Queue 2

↓

Uses entire quantum

↓

Queue 3

Advantages

  • Adapts automatically
  • Good response
  • Prevents starvation

Disadvantages

  • Complex implementation
  • Difficult tuning

Used In

Modern Linux (conceptually)
Windows
macOS


7. EDF (Earliest Deadline First)

Used in Real-Time Systems.

Definition

The task with the nearest deadline executes first.


Example

TaskDeadline
T110 ms
T26 ms
T315 ms

Execution

T2

↓

T1

↓

T3

Dynamic Priority

Priority changes continuously.

Closer deadline

Higher priority


Advantages

  • Very efficient
  • Maximum CPU utilization
  • Optimal scheduling for many preemptive uniprocessor real-time workloads

Disadvantages

  • More complex
  • Requires accurate deadline information
  • Less predictable than fixed-priority scheduling for certification in some safety-critical domains

Used In

  • Aerospace
  • Robotics
  • Medical devices
  • Telecom
  • Some real-time Linux configurations

Note: OSEK/AUTOSAR OS does not use EDF. It uses fixed-priority preemptive scheduling because static priorities are simpler to analyze and certify for automotive safety.


Scheduling Algorithm Comparison

AlgorithmPreemptiveStarvationResponse TimeReal-Time SuitableComplexity
FCFSNoPoorNoVery Low
SJF❌ (SRTF: Yes)YesGoodNoMedium
Round RobinNoVery GoodLimitedLow
Priority✅ / ❌YesExcellentYesLow
Multilevel QueuePossibleGoodLimitedMedium
Multilevel Feedback QueueRareExcellentNoHigh
EDFNo (under schedulable conditions)ExcellentYesHigh

Which Scheduling Algorithm is Used Where?

Operating System / PlatformScheduling Algorithm
OSEK OSFixed Priority Preemptive
AUTOSAR OSFixed Priority Preemptive
FreeRTOSFixed Priority Preemptive (optional cooperative mode)
Linux (normal tasks)Completely Fair Scheduler (CFS)
Linux Real-Time (SCHED_FIFO, SCHED_RR)Fixed Priority
WindowsPriority-based with dynamic adjustments
Aerospace RTOSEDF or Fixed Priority
Medical RTOSEDF or Fixed Priority

Interview Tips

A common interview question is:

"Why does AUTOSAR use Fixed Priority Scheduling instead of EDF?"

A strong answer is:

  • Fixed priorities provide deterministic behavior.
  • Worst-case response time analysis is simpler.
  • Easier to certify for standards such as ISO 26262.
  • Lower runtime overhead than dynamic-priority algorithms like EDF.
  • Most automotive workloads have well-defined periodic tasks that map well to fixed priorities.

This demonstrates not only that you know the algorithms, but also why specific industries choose one over another.