Trace

CPU scheduling simulator

Pick an algorithm, enter your processes and press play. Every scheduling decision comes with the reason for it.

Processes

Name Arrival Burst Priority Remove
Length of each slice
Ties at the same momentA process that arrives just as a slice ends joins the queue before the preempted process.
The running process always finishes first.
Highest priority1 is the highest priority.
Why this happened

P1 and P2 arrived at the same time. P1 has the lower process number, so it runs first.

Ready queue, next in line first
    Decision log

    Every moment something was decided. Choose a line to move the playhead there.

      Keyboard shortcuts
      Space
      Play or pause
      Left Right
      Step back or forward one unit
      Home End
      Jump to the start or the end
      R
      Reset
      [ ]
      Slower or faster
      T
      Switch light or dark theme

      Shortcuts are off while you type in a field.

      Results

      Process Arrival Burst Finished Turnaround Waiting Response
      Average

       

      Turnaround is finished - arrival. Waiting is turnaround - burst. Response is first run - arrival. CPU utilization is total burst / last finish.

      What CPU scheduling decides

      A computer usually has more processes ready to run than it has processors. CPU scheduling is the rule that decides which ready process gets the CPU next, and for how long. The five algorithms on this page all answer that question differently: by arrival order, by job length, by remaining work, by importance, or by taking turns. The simulator above runs any of them on the same processes, so you can switch and watch the timeline change.

      Every schedule here is shown as a timeline, which textbooks call a Gantt chart: time runs left to right, the top lane shows who has the CPU, and each process has its own lane with its runs and its waiting stretches.

      How schedules are measured

      Three numbers per process describe how a schedule treated it. Turnaround time is how long the process spent in the system, from arrival to finish. Waiting time is the part of that it spent ready but not running. Response time is how long it waited before it ran for the first time. Averages over all processes let you compare algorithms; CPU utilization and throughput describe the schedule as a whole.

      • Turnaround time = finished - arrival
      • Waiting time = turnaround - burst
      • Response time = first run - arrival
      • CPU utilization = total burst / last finish, and throughput = processes / last finish

      Which one should I use?

      There is no single best algorithm; each one wins on a different measure. Use this table as a starting point, then try your own processes in the compare view.

      How the five scheduling algorithms compare
      AlgorithmPreemptiveCan starveBest forMain weakness
      FCFSNoNoSimple batches where arrival order is fairShort jobs wait behind long ones
      SJFNoYes, long jobsLow average waiting time when job lengths are knownNeeds burst lengths in advance
      SRTFYesYes, long jobsThe lowest average waiting time, if switching is cheapMany switches, needs remaining times
      PriorityEitherYes, low priority, unless aging is usedWork where some processes matter moreImportance can leave long waits
      Round RobinYesNoInteractive use and fair response timesHigher average turnaround; depends on the quantum

      A few rules of thumb follow from the table. If you care about average waiting time and know how long jobs take, the shortest-first family (SJF, SRTF) is hard to beat. If you care about every process getting a turn quickly, Round Robin is the usual answer. If processes differ in importance, Priority expresses that directly, and FCFS remains the baseline the others are measured against.

      What Trace assumes

      The simulator follows the classic textbook model: one CPU, time in whole units, each process needing one CPU burst with no input or output in between, and switching between processes taking no time. Real schedulers deal with all of these, but exam questions usually do not, and the simple model makes every decision visible. The tie-break rules are stated on each algorithm's page and, where textbooks differ, you can switch them.

      The five algorithms

      Spotted a mistake?

      If something on this page looks wrong, please tell me what and why.

      Email: abdul at abmans dot com