Skip to content
GATEiit

GATE CSE · Operating System

CPU and I/O scheduling

How the OS picks the next process to run (FCFS, SJF, SRTF, priority, round robin) and the next disk request to serve (FCFS, SSTF, SCAN, C-SCAN, LOOK), and how to compute waiting, turnaround and head movement.

Before you start

  • Processes, process states and context switches →

    Scheduling moves processes between the ready and running states; every preemption is a context switch.

  • Queues →

    The ready queue of round robin is a FIFO queue; the order of insertion decides the answer.

  • Reading a timeline

    Every numerical starts by drawing a Gantt chart from arrival and burst times.

This topic comes before: File systems

Concept notes

1. The vocabulary: arrival, burst, completion

Each process has an arrival time (AT, when it enters the ready queue) and a CPU burst time (BT, how long it needs the CPU). From the schedule you read its completion time (CT).

  • Turnaround time (TAT) is the time from arrival to completion: TAT=CT−AT.
  • Waiting time (WT) is the time spent in the ready queue: WT=TAT−BT (for a process that does no I/O).
  • Response time is the time from arrival to the first time it gets the CPU.

GATE questions almost always ask for an average over all processes, so tabulate CT, TAT and WT per process before averaging.

2. Preemptive vs non-preemptive

A non-preemptive scheduler lets the running process keep the CPU until it finishes its burst or blocks. A preemptive scheduler can take the CPU away, for example when a shorter job arrives (SRTF) or the time quantum ends (round robin).

The scheduler is invoked when a process (1) goes from running to waiting, (2) terminates, (3) goes from running to ready, or (4) goes from waiting to ready. Non-preemptive scheduling acts only in cases 1 and 2.

3. The CPU scheduling algorithms

Algorithm Picks Preemptive? Note
FCFS earliest arrival No Simple; convoy effect: short jobs wait behind a long one
SJF shortest burst among arrived jobs No Minimum average waiting time among non-preemptive schedules
SRTF shortest remaining time Yes Optimal average waiting time overall; needs burst estimates
Priority highest priority Either Can starve low priority jobs; fix with aging
Round robin (RR) next in FIFO queue, for at most q Yes No starvation; large q → FCFS, tiny q → overhead

SJF, SRTF and priority scheduling can starve a process; FCFS and round robin cannot. In RR with n ready processes, a process waits at most (n−1)q before its next turn.

P1P2P4P1P3015101726
SRTF on P1(0, 8), P2(1, 4), P3(2, 9), P4(3, 5): P2 preempts P1 at time 1

4. Round robin: the queue order rule

Round robin answers depend on one convention: when a process's quantum expires at the same instant a new process arrives, the newly arrived process joins the ready queue first, then the preempted one goes to the tail. GATE solutions use this order unless the question states otherwise.

A process whose remaining burst is less than q runs only for that remaining time and leaves; the next process starts at once.

With a context-switch cost s and every burst at least q, CPU efficiency is qq+s.

5. Disk (I/O) scheduling

For a disk, the scheduler orders pending track (cylinder) requests to reduce total head movement (the sum of distances travelled).

  • FCFS: serve in arrival order.
  • SSTF: serve the nearest pending request next. Low movement, but can starve far requests.
  • SCAN (elevator): move in one direction to the end of the disk, serving requests, then reverse.
  • LOOK: like SCAN, but reverse at the last request instead of the disk end.
  • C-SCAN / C-LOOK: serve in one direction only; then jump back to the start (C-SCAN: to track 0; C-LOOK: to the lowest request) and continue. Check whether the question counts the return jump.

Read the question for the head's starting position, its direction, and the disk's last track number.

Formulas to remember

Turnaround timeCompletion time minus arrival time
TAT=CT−AT
Waiting timeFor CPU-only processes
WT=TAT−BT
Response time
RT=first start−AT
Throughput
Throughput=processes completedtotal time
Round robin efficiencyQuantum q, context switch s, every burst at least q
η=qq+s
Round robin worst wait for a turnn processes in the ready queue
(n−1) q
Exponential averaging (SJF burst prediction)tn = actual last burst, τn = last prediction, 0≤α≤1
τn+1=α tn+(1−α) τn

Common mistakes

  • Using burst time instead of arrival time when computing turnaround: TAT is CT − AT, not CT − BT.
  • In round robin, putting the preempted process back before a process that arrived at the same instant.
  • Forgetting that SRTF re-checks only when a process arrives or finishes, not at every time unit.
  • In SCAN, stopping at the last request (that is LOOK); SCAN goes to the disk end.
  • Counting (or not counting) the C-SCAN return jump without reading what the question asks.

Worked examples

Try each step yourself, then reveal the working.

Example 1: FCFS, SJF and SRTF on the same four processes

numerical

Processes (arrival, burst): P1 (0, 8), P2 (1, 4), P3 (2, 9), P4 (3, 5). Find the average waiting time under FCFS, non-preemptive SJF and SRTF.

  1. Step 1: Draw the FCFS schedule.

    Try it on paper first.

Example 2: Round robin with quantum 2

numerical

Processes (arrival, burst): P1 (0, 5), P2 (1, 3), P3 (2, 1). Round robin with q=2. Find the average turnaround and waiting time.

  1. Step 1: Run P1's first quantum and update the queue.

    Try it on paper first.

Example 3: Disk head movement: FCFS vs SSTF

numerical

The head is at track 53. Pending requests in order: 98, 183, 37, 122, 14, 124, 65, 67. Find the total head movement under FCFS and SSTF.

  1. Step 1: FCFS: add the distances in request order.

    Try it on paper first.

Example 4: Which schedulers can starve a process?

conceptual

Among FCFS, SJF, SRTF, priority and round robin, which can make a ready process wait forever, and how is that fixed?

  1. Step 1: Ask: can newly arriving jobs keep jumping ahead?

    Try it on paper first.

Previous year questions

16 official GATE CSE questions on this topic, newest first.

Practise these 16 PYQs →

Topic test

10 questions: up to 4 official PYQs and original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE CSE syllabus; being checked by a reviewer. Updated 2026-11-16. Spotted a mistake? Use Report an issue on any question, or contact us.