CPU scheduling and deadlock – FCFS, SJF, round robin and priority

Computer ScienceComputers & HardwareAges 16–17

Loading…

Use with my class ✨ Customize with AI Report a problem

Enter processes with arrival times, burst times and priorities, choose FCFS, SJF, SRTF, round robin (set the time quantum) or priority scheduling, and watch the Gantt chart grow one time unit at a time alongside the ready queue and the process-state diagram. A results table gives waiting, turnaround and response times and the number of context switches, and a comparison table puts all six algorithms side by side. The Deadlock tab lets two or three processes compete for resources, draws the resource-allocation graph and shows how requesting resources in the same order prevents circular wait.

Lesson: Operating systems: CPU scheduling (FCFS, SJF, SRTF, round robin, priority), process states, context switching, starvation and deadlock

What it shows

An operating system runs many processes on one CPU by deciding which ready process runs next. FCFS runs them in arrival order; SJF and SRTF pick the shortest remaining burst; round robin gives each process a time quantum in turn; priority scheduling picks the most urgent. Turnaround time = finish time − arrival time, and waiting time is the time spent in the ready queue. Long jobs or low-priority jobs can starve unless aging raises their priority. Deadlock happens when processes each hold a resource and wait in a circle for another; requesting resources in a fixed order prevents it.

How to use

In CPU scheduling, edit the process table or pick a Preset, choose an Algorithm and Quantum q, then press Play or Step to build the Gantt chart. Read the Results and Compare tables; tick Aging or I/O requests to see their effect. In Deadlock, choose the Resource request order, Processes and Start gap, press Play, and press Break deadlock when the graph shows a cycle.

Parameters you can change

  • Starting tab CPU scheduling, Deadlock
  • Scheduling algorithm FCFS – first come, first served, SJF – shortest job first (non-preemptive), SRTF – shortest remaining time (preemptive), Round robin, Priority (non-preemptive), Priority (preemptive)
  • Time quantum q (round robin) 1–8
  • Preset process set Textbook example (5 processes), Long job first, Stream of high-priority jobs
  • Processes make I/O requests
  • Aging (priority rises while waiting)
  • Resource request order Opposite orders, Same order (lowest number first)
  • Processes in the Deadlock tab 2 processes, 3 processes
  • Start gap between processes 0–6 steps

Questions to explore

  1. With the Long job first preset, why does round robin give a much lower average waiting time than FCFS?
  2. How do context switches and response time change as you raise the quantum q from 1 to 8?
  3. Why can deadlock never happen when every process requests resources in the same order?