CPU Scheduling Algorithms
How the OS decides which process gets the CPU next.
FCFS (First Come First Serve)
Processes are executed in the order they arrive. Simple to implement, but can cause the 'convoy effect' â short processes waiting a long time behind one long process.
SJF (Shortest Job First)
The process with the smallest execution time runs next, minimizing average waiting time. The challenge: the OS often can't know a process's exact runtime in advance.
Round Robin
Each process gets a fixed time slice (quantum) in rotation. This is fair and responsive, making it ideal for time-sharing systems â but a very small quantum increases context-switching overhead.
đ Real-World Use
Your phone feels responsive even with 20 apps 'open' because the OS uses Round-Robin-like scheduling, quickly switching between them so each gets a tiny slice of CPU time, creating the illusion of true multitasking.
đĄ Pro Tip
When asked 'which scheduling algorithm is best?', the correct interview answer is 'it depends on the goal' â FCFS for simplicity, SJF for minimizing wait time (if job length is known), Round Robin for fairness in interactive systems. There's no single 'best' algorithm.
đ§Ē Quick Self-Test
Check what you just learned â no pressure, just practice.
1. Which scheduling algorithm can cause the 'convoy effect'?
2. What does Round Robin give each process?