โ† Back to all tools

๐Ÿ–ฅ๏ธ How Does Your Computer Decide What to Do First?

OS Process Scheduling Simulator

Your computer runs lots of programs at once โ€” but the CPU can only do one thing at a time. How does it decide what goes first?

CS GCSE ยง1.7 CS A-Level Unit 4

๐Ÿค” What is process scheduling?

A process is just a program that's running โ€” Spotify, Chrome, a game. Your CPU can only work on one process at a time, switching between them so fast it looks like they're all running simultaneously.

A scheduling algorithm is the rule the operating system uses to decide which process gets the CPU next.

๐Ÿ• Real-world analogy: Imagine a pizza shop with one oven. Five orders come in at different times for different sizes of pizza. How do you decide which one to cook first?
  • First Come First Served โ€” cook them in the order they arrived
  • Shortest Job First โ€” cook the smallest pizza first (quickest to finish)
  • Round Robin โ€” give each pizza 2 minutes in the oven, then rotate
  • Priority โ€” VIP customers go first
๐ŸŽฌ

Choose a scenario

Pick a real-world situation to see scheduling in action, or build your own below.

๐Ÿ“ฑ

Your Phone

Spotify, Instagram, WhatsApp and a game all competing for your phone's CPU

๐Ÿ–จ๏ธ

School Printer Queue

5 students send print jobs โ€” some big, some small. Who prints first?

๐ŸŽฎ

Gaming PC

Fortnite needs lots of CPU, while Discord and Chrome run in the background

โš™๏ธ

Build Your Own

Create your own processes and experiment

โš™๏ธ

Setup โ€” choose the scheduling rule

FCFS = processes run in the order they arrive. Just like a queue in a shop โ€” first person in line gets served first. Simple and fair, but if one process takes ages, everyone behind it has to wait (this is called the convoy effect).
or use a scenario above
Process Arrival Time Burst Time Priority
๐Ÿ“–

Scheduling algorithms explained

AlgorithmHow it worksReal-world exampleProblem
FCFS Run processes in arrival order Queue at a shop Convoy effect โ€” slow job blocks everyone
SJF Shortest job runs first "10 items or fewer" express checkout Starvation โ€” long jobs may never run
Round Robin Each process gets a fixed time slice, then goes to the back of the queue Taking turns on a games console Context switching overhead
Priority Most important process runs first A&E triage โ€” most urgent patient first Starvation โ€” low priority may wait forever
Process states:
๐Ÿ†• New โ€” just created โณ Ready โ€” waiting for CPU ๐Ÿƒ Running โ€” using CPU now โธ๏ธ Waiting โ€” needs I/O โœ… Terminated โ€” done
๐Ÿง  What next? Try running the same processes with different algorithms. Which one gives the lowest average waiting time? Is the "best" algorithm always the same?