IAE Academy

GATE CS

CPU scheduling

CPU scheduling decides which ready process gets the processor next, and for how long. GATE questions ask you to draw the Gantt chart for FCFS, SJF, SRTF, HRRN, priority and round robin, then compute waiting, turnaround and response times. The exact tie rules and preemption points decide the answer.

8 previous-year questions · 8 solved · 6 practice questions

Criteria and definitions

The CPU scheduler picks one process from the ready queue whenever the CPU becomes free or a preemption happens. A schedule is judged by a few standard measures. Convention used in these notes: time is in milliseconds and the Gantt chart starts at time 0. When two processes tie on the selection key (equal burst in SJF, equal remaining time in SRTF, equal priority), the one that arrived earlier wins. If they also arrived at the same instant, the one with the smaller index wins. In a preemptive algorithm, the running process is preempted only by a process that is strictly better. In round robin, a process that arrives at the same instant a running process is preempted joins the queue first, ahead of the preempted process. Always follow the rule a question states over these defaults.

Term

Meaning

Arrival time (AT)

Instant the process enters the ready queue

Burst time (BT)

Total CPU time the process needs

Completion time (CT)

Instant the process finishes

Turnaround time (TAT)

Time from arrival to completion

Waiting time (WT)

Total time spent in the ready queue, not running

Response time (RT)

Time from arrival to the first time the CPU is given to it

Throughput

Number of processes completed per unit time

CPU utilisation

Fraction of time the CPU runs processes

TURNAROUND TIME

Holds for every scheduling algorithm.

WAITING TIME

Valid when the process has a single CPU burst and does no I/O. With I/O bursts, WT = TAT − (total CPU time) − (total I/O time).

RESPONSE TIME

In a non-preemptive algorithm, RT equals WT when each process has a single CPU burst and does no I/O.

UTILISATION AND THROUGHPUT

Total elapsed time runs from time 0 to the last completion unless the question defines it otherwise. Idle gaps and context-switch time count as not busy.

EXAM TIP

Non-preemptive means a running process keeps the CPU until it finishes or blocks. Preemptive means the scheduler may take the CPU away, for example when a more suitable process arrives or a time quantum expires.

Non-preemptive algorithms: FCFS, SJF, HRRN and priority

FCFS (first come, first served) serves processes in order of arrival. It is non-preemptive and simple, but one long process delays all the short ones behind it. This is the convoy effect.

Take three processes arriving together at time 0 in the order P1, P2, P3 with bursts 24, 3 and 3. FCFS gives waiting times 0, 24 and 27, so the average is 17. Running them in the order P2, P3, P1 gives 0, 3 and 6, an average of 3. The work is the same; only the order makes the average so much worse.

SJF (shortest job first, non-preemptive): whenever the CPU is free, choose the ready process with the smallest burst time. When all processes are available at the same time, SJF gives the minimum average waiting time of any schedule. With different arrival times this guarantee no longer holds for non-preemptive SJF. Its drawbacks: burst times must be known (or predicted) in advance, and a long process can starve if short ones keep arriving.

Priority scheduling: each process has a priority, and the CPU goes to the highest-priority ready process. Unless a question says otherwise, these notes take a smaller number to mean higher priority; always read the statement. In the non-preemptive form, a newly arrived higher-priority process waits for the running one to finish. Low-priority processes may starve. The cure is ageing, which gradually raises the priority of a process the longer it waits. SJF is priority scheduling where the priority is the inverse of the (predicted) next CPU burst.

HRRN (highest response ratio next) is non-preemptive. Whenever the CPU is free, it computes for every ready process the response ratio below and runs the process with the largest ratio. Short jobs get a high ratio quickly, and a long job's ratio grows the longer it waits, so HRRN favours short jobs without starving long ones.

HRRN RESPONSE RATIO

W = time the process has waited so far in the ready queue, S = its burst time. Recompute it at every instant the CPU becomes free.

  1. Start at time 0. If no process has arrived, the CPU is idle until the first arrival.

  2. When the CPU is free at time , collect all unfinished processes with .

  3. Pick by the rule: earliest arrival (FCFS), smallest burst (SJF), largest response ratio (HRRN) or best priority (priority). Break ties by the convention above.

  4. Run the chosen process to completion, record CT, then repeat from time CT.

WORKED EXAMPLE

Use HRRN. Processes (AT, BT): P1 (0, 3), P2 (2, 6), P3 (4, 4), P4 (6, 5), P5 (8, 2). Find the average turnaround and waiting times.

Solution
  1. t = 0: only P1. It runs 0 to 3.

  2. t = 3: only P2 has arrived. It runs 3 to 9.

  3. t = 9: ratios are P3 (5 + 4)/4 = 2.25, P4 (3 + 5)/5 = 1.6, P5 (1 + 2)/2 = 1.5. P3 runs 9 to 13.

  4. t = 13: ratios are P4 (7 + 5)/5 = 2.4, P5 (5 + 2)/2 = 3.5. P5 runs 13 to 15, then P4 runs 15 to 20.

  5. CT: P1 = 3, P2 = 9, P3 = 13, P4 = 20, P5 = 15. TAT: 3, 7, 9, 14, 7, sum 40.

  6. WT = TAT − BT: 0, 1, 5, 9, 5, sum 20.

Answer: Average turnaround time = 40/5 = 8 ms; average waiting time = 20/5 = 4 ms.

Predicting the next CPU burst. SJF and SRTF need burst lengths that are not known in advance. The usual estimate is the exponential average of the measured bursts. With the prediction never changes; with it equals the last actual burst. Expanded, , so older bursts carry geometrically smaller weight.

EXPONENTIAL AVERAGING

t_n = actual length of the nth CPU burst, tau_n = its predicted value, tau_1 = the given initial guess.

EXAM TIP

In non-preemptive SJF and HRRN, decide only at the instants the CPU becomes free. A shorter process that arrives while another is running does not interrupt it.

Preemptive algorithms: SRTF and preemptive priority

SRTF (shortest remaining time first) is the preemptive form of SJF. Whenever a process arrives, compare its burst with the remaining time of the running process. If it is strictly smaller, the running process is preempted. For a given set of processes with known arrival and burst times, and ignoring context-switch overhead, SRTF gives the minimum average waiting time (and average turnaround time) of any scheduling algorithm. Long processes may starve.

Preemptive priority works the same way with priorities: a newly arrived process whose priority is strictly better than the running one takes the CPU. If the priorities are equal, the running process continues unless the question says otherwise. Without ageing, priorities do not change while processes wait, so decisions are needed only at arrivals and completions.

LJF (longest job first, non-preemptive) and LRTF (longest remaining time first, its preemptive form) are the mirror images of SJF and SRTF: they pick the largest burst or remaining time. Under LRTF the remaining times often become equal, so the tie rule a question states decides the Gantt chart. Apply it at every tie, including a tie with the running process.

Algorithm

Preemptive?

Selection key

Starvation?

Notes

FCFS

No

Arrival time

No

Convoy effect

SJF

No

Smallest burst

Yes (long jobs)

Minimum average WT when all processes arrive together

SRTF

Yes

Smallest remaining time

Yes (long jobs)

Minimum average WT of any algorithm (no switch overhead)

HRRN

No

Largest (W + S)/S

No

Favours short jobs, ages long ones

LJF / LRTF

LJF no, LRTF yes

Largest burst / remaining time

Yes (short jobs)

Large average waiting time

Priority (NP or P)

Either

Best priority

Yes (low priority)

Ageing removes starvation

Round robin

Yes

Queue order, time quantum

No

Good response time

WORKED EXAMPLE

Use SRTF. Processes (AT, BT): P1 (0, 7), P2 (2, 4), P3 (4, 1), P4 (5, 4). Find the average waiting time and average turnaround time.

Solution
  1. t = 0: only P1, so it runs. At t = 2 P2 arrives with 4, while P1 has 5 left. 4 < 5, so P2 preempts P1.

  2. P2 runs from 2. At t = 4 P3 arrives with 1, while P2 has 2 left. 1 < 2, so P3 preempts P2.

  3. P3 runs 4 to 5 and finishes. At t = 5 P4 arrives with 4; the remaining times are P1 = 5, P2 = 2, P4 = 4. P2 is smallest and runs 5 to 7.

  4. Next P4 (4) runs 7 to 11, then P1 (5) runs 11 to 16.

  5. Gantt: P1 [0,2], P2 [2,4], P3 [4,5], P2 [5,7], P4 [7,11], P1 [11,16].

  6. CT: P1 = 16, P2 = 7, P3 = 5, P4 = 11. TAT = CT − AT: 16, 5, 1, 6, sum 28.

  7. WT = TAT − BT: 9, 1, 0, 2, sum 12.

Answer: Average waiting time = 12/4 = 3 ms; average turnaround time = 28/4 = 7 ms.

EXAM TIP

In SRTF always compare the arriving burst with the running process's REMAINING time, not its original burst.

Round robin and the time quantum

Round robin (RR) is FCFS with preemption by a timer. The ready queue is a FIFO. The process at the head is dispatched for at most one time quantum . If it needs more, it is preempted and goes to the back of the queue. If it finishes or blocks earlier, the next process starts at once. RR is designed for time-sharing: every process gets a turn within a bounded time, and there is no starvation.

  1. Put the processes that have arrived at time 0 in the queue.

  2. Run the process at the head for .

  3. During that run, add every process that arrives to the queue. A process that arrives exactly when the quantum expires is queued BEFORE the preempted process (the convention above).

  4. If the process is not finished, append it to the back of the queue.

  5. Repeat. If the queue is empty and processes remain, the CPU is idle until the next arrival.

RR TURN BOUND

For n processes that all keep using full quanta, with a context switch of s ms between any two processes. The second form is the largest quantum for which every process gets the CPU again within T ms. With s = 0, the k-th process in a queue formed at time 0 first gets the CPU within (k − 1)q.

Quantum

Effect

Very large (larger than every burst)

RR behaves like FCFS

Very small

Good response, but context-switch overhead dominates

Comparable to context-switch time

Large share of time is wasted

RR EFFICIENCY WITH SWITCH TIME

Valid when every process uses its full quantum q and each dispatch costs a context switch of s ms.

WORKED EXAMPLE

Round robin with ms. Processes (AT, BT): P1 (0, 5), P2 (1, 3), P3 (2, 1), P4 (4, 2). Context switches cost nothing. A process arriving when a quantum expires is queued before the preempted process. Find each waiting time.

Solution
  1. t = 0: queue [P1]. P1 runs 0 to 3 (2 left). P2 (t = 1) and P3 (t = 2) arrive during this run, then P1 rejoins: queue [P2, P3, P1].

  2. P2 runs 3 to 6 and finishes. P4 arrived at t = 4: queue [P3, P1, P4].

  3. P3 runs 6 to 7 and finishes. P1 runs 7 to 9 and finishes. P4 runs 9 to 11 and finishes.

  4. Gantt: P1 [0,3], P2 [3,6], P3 [6,7], P1 [7,9], P4 [9,11].

  5. CT: 9, 6, 7, 11. TAT = CT − AT: 9, 5, 5, 7. WT = TAT − BT: 4, 2, 4, 5.

Answer: Waiting times P1 = 4, P2 = 2, P3 = 4, P4 = 5 ms; average 3.75 ms.

EXAM TIP

A larger quantum does not always lower the average turnaround time. Ignoring overhead, RR's average turnaround is never lower than SRTF's for the same processes, because SRTF is optimal. RR's strength is response time.

Multilevel queues and multilevel feedback queues

Multilevel queue (MLQ): the ready queue is split into separate queues, for example system, interactive and batch processes. Each process is permanently assigned to one queue, and each queue has its own algorithm (say RR for interactive, FCFS for batch). The queues themselves are scheduled either by fixed priority or by time-slicing among queues (for instance 80% of CPU time to one queue and 20% to another). Under fixed priority, a lower queue runs only when all higher ones are empty, so starvation is possible.

Multilevel feedback queue (MLFQ) lets a process move between queues. A typical design: queue 0 is RR with a small quantum, queue 1 is RR with a larger quantum, and the last queue is FCFS. A new process enters queue 0 and is demoted to the next queue if it does not finish within its quantum. A process that waits too long in a low queue may be promoted, which is ageing. CPU-bound processes sink to the lower queues, and I/O-bound processes stay in the upper ones.

  1. Number of queues.

  2. Scheduling algorithm of each queue.

  3. Rule to upgrade a process to a higher queue.

  4. Rule to demote a process to a lower queue.

  5. Rule to decide which queue a new process enters.

EXAM TIP

MLFQ is the most general of these schemes and the most complex to configure. Fixed-priority MLQ can starve; MLFQ with ageing does not.

Context switches, idle time, and I/O-bound and CPU-bound processes

A context switch saves the state of one process and loads another. It is pure overhead: the CPU does no useful work during it. Default in these notes: when a switch time is given, add to the timeline each time the CPU moves from one process to a different one. Do not add it at time 0, at the end, or when the same process continues. Some questions also charge a switch at the start, at the end, or after an idle gap. When a question states its own rule, follow it. Idle time is time when no process is ready; the CPU waits until the next arrival or I/O completion.

A process alternates between CPU bursts and I/O bursts. An I/O-bound process has many short CPU bursts; a CPU-bound process has few long ones. Favouring short CPU bursts, as SJF, SRTF and MLFQ do, tends to keep the I/O devices busy while long CPU work fills the gaps, and improves response for interactive processes.

For a process with I/O bursts, time spent doing I/O is not waiting time. Build the timeline: after a CPU burst the process goes to its I/O for the stated time, then rejoins the ready queue as if it had just arrived. Unless the question says that processes share one I/O device and must queue for it, assume each process's I/O overlaps freely with the others. Count waiting time only while a process sits in the ready queue.

CPU UTILISATION WITH OVERHEADS

Use when context-switch time and idle gaps are given or can be read from the Gantt chart. The denominator is the total elapsed time.

WORKED EXAMPLE

Round robin, ms. P1, P2, P3 all arrive at time 0 in this order with bursts 10, 6 and 4 ms. Every switch from one process to a different one costs 1 ms, with no switch at time 0. Find the completion time of the last process and the CPU utilisation.

Solution
  1. P1 runs 0 to 4 (6 left). Switch 4 to 5.

  2. P2 runs 5 to 9 (2 left). Switch 9 to 10.

  3. P3 runs 10 to 14 and finishes. Switch 14 to 15.

  4. P1 runs 15 to 19 (2 left). Switch 19 to 20.

  5. P2 runs 20 to 22 and finishes. Switch 22 to 23.

  6. P1 runs 23 to 25 and finishes. The total is 25 ms, containing 5 switches.

  7. Useful work = 10 + 6 + 4 = 20 ms. Utilisation = 20/25 = 0.8.

Answer: Last completion at 25 ms; CPU utilisation = 80%.

EXAM TIP

The convoy effect also appears with I/O: one CPU-bound process holding the CPU makes the I/O-bound processes queue up while the I/O devices sit idle.

PREVIOUS-YEAR QUESTIONS

8 questions from the CS papers

Try each question first, then open the answer. We placed each question under a topic ourselves; the exam paper does not label topics.

See these papers in full: GATE CSE 2026 Set 1 · GATE CSE 2026 Set 2 · GATE CSE 2025 Set 1 · GATE CSE 2025 Set 2 · GATE CSE 2024 Set 2 · GATE CSE 2023 · GATE CSE 2022 · GATE CSE 2020

GATE 2026 CS1 Q.64

GATE 2026 · CS1Q.64 · 2 marks · NAT

Consider a CPU that has to execute two types of processes. The first type, Actuators (A), requires a CPU burst of 6 seconds. The second type, Controllers (C), requires a CPU burst of 8 seconds. A new process of type A arrives at time , 20, 30, 40, and 50 (in seconds). Similarly, a new process of type C arrives at time , 22, 33, 44, and 55 (in seconds). The CPU scheduling policy is First Come First Serve (FCFS). The first process of type A starts running at seconds. The average waiting time (in seconds) for the 10 processes is ________. (rounded off to one decimal place)

Answer and solution
See the question in the paper
GATE 2026 CS1 Q.64: answer and solution

GATE 2025 CS1 Q.38

GATE 2025 · CS1Q.38 · 2 marks · MCQ

A computer has two processors, and . Four processes with CPU bursts of 20, 16, 25, and 10 milliseconds, respectively, arrive at the same time and these are the only processes in the system. The scheduler uses non-preemptive priority scheduling, with priorities decided as follows:
- uses priority of execution for the processes as, , i.e., and have highest and lowest priorities, respectively.
- uses priority of execution for the processes as, , i.e., and have highest and lowest priorities, respectively.

A process is scheduled to a processor , if the processor is free and no other process is waiting with higher priority. At any given point of time, a process can be allocated to any one of the free processors without violating the execution priority rules. Ignore the context switch time. What will be the average waiting time of the processes in milliseconds?

  1. (A)

    9.00

  2. (B)

    8.75

  3. (C)

    6.50

  4. (D)

    7.50

Answer and solution
See the question in the paper
GATE 2025 CS1 Q.38: answer and solution

GATE 2025 CS2 Q.26

GATE 2025 · CS2Q.26 · 1 mark · MCQ

Processes arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times.

Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?

  1. (A)

    22

  2. (B)

    15

  3. (C)

    37

  4. (D)

    19

Answer and solution
See the question in the paper
GATE 2025 CS2 Q.26: answer and solution

GATE 2024 CS2 Q.37

GATE 2024 · CS2Q.37 · 2 marks · MCQ

Consider a single processor system with four processes A, B, C, and D, represented as given below, where for each process the first value is its arrival time, and the second value is its CPU burst time.

A (0, 10), B (2, 6), C (4, 3), and D (6, 7).

Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First (SRTF) and Non-Preemptive Shortest Job First (NP-SJF) CPU scheduling algorithms are applied to the processes?

  1. (A)

    SRTF = 6, NP-SJF = 7

  2. (B)

    SRTF = 6, NP-SJF = 7.5

  3. (C)

    SRTF = 7, NP-SJF = 7.5

  4. (D)

    SRTF = 7, NP-SJF = 8.5

Answer and solution
See the question in the paper
GATE 2024 CS2 Q.37: answer and solution

GATE 2022 CS Q.42

GATE 2022 · CSQ.42 · 2 marks · MCQ

Consider four processes P, Q, R, and S scheduled on a CPU as per round robin algorithm with a time quantum of 4 units. The processes arrive in the order P, Q, R, S, all at time t = 0. There is exactly one context switch from S to Q, exactly one context switch from R to Q, and exactly two context switches from Q to R. There is no context switch from S to P. Switching to a ready process after the termination of another process is also considered a context switch. Which one of the following NOT possible as CPU burst time (in time units) of these processes?

  1. (A)

    P = 4, Q = 10, R = 6, S = 2

  2. (B)

    P = 2, Q = 9, R = 5, S = 1

  3. (C)

    P = 4, Q = 12, R = 5, S = 4

  4. (D)

    P = 3, Q = 7, R = 7, S = 3

Answer and solution
See the question in the paper
GATE 2022 CS Q.42: answer and solution

GATE 2020 CS Q.50

GATE 2020 · CSQ.50 · 2 marks · NAT

Consider the following set of processes, assumed to have arrived at time 0. Consider the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR, assume that the processes are scheduled in the order .

If the time quantum for RR is 4 ms, then the absolute value of the difference between the average turnaround times (in ms) of SJF and RR (round off to 2 decimal places) is ______.

Answer and solution
See the question in the paper
GATE 2020 CS Q.50: answer and solution

OTHER EXAMS

ISRO: 3 questions

From ISRO's Scientist/Engineer written test: ISRO CS 2025, ISRO CS 2023. They are not counted in the GATE numbers on this page.

ISRO CS 2025 Q.67

ISRO 2025 · CSQ.67 · 1 mark · MCQ

For the following list of processes, the average turnaround time and average waiting time using FCFS algorithm is :

ProcessArrival Time (ms)Execution Time (ms)
P1624
P203
P333
ISRO CS 2025 question 67: A table with three columns (Process, Arrival Time in ms, Execution Time in ms) and three rows: P1 arrives at 6 and…Tap to open full size
Figure from the ISRO CS 2025 paper. It is part of the question.
Figure description

A table with three columns (Process, Arrival Time in ms, Execution Time in ms) and three rows: P1 arrives at 6 and executes 24; P2 arrives at 0 and executes 3; P3 arrives at 3 and executes 3.

  1. (A)

    Average Turnaround time 30 ms and Average Waiting Time 4.5 ms

  2. (B)

    Average Turnaround time 13 ms and Average Waiting Time 3 ms

  3. (C)

    Average Turnaround time 10 ms and Average Waiting Time 0 ms

  4. (D)

    Average Turnaround time 24 ms and Average Waiting Time 0 ms

Answer and solution
ISRO CS 2025 Q.67: answer and solution

ISRO CS 2025 Q.68

ISRO 2025 · CSQ.68 · 1 mark · MCQ

68. In the context of Operating system process scheduling, if W represents Wait Time, R represents Run Time, T represents Turnaround time, S represents Response time, then which of the following is correct option with respect to given diagram?

ISRO CS 2025 question 68: A horizontal time axis (arrow labelled 'time' at right) with four vertical tick marks labelled, left to right, Arrival…Tap to open full size
Figure from the ISRO CS 2025 paper. It is part of the question.
Figure description

A horizontal time axis (arrow labelled 'time' at right) with four vertical tick marks labelled, left to right, Arrival, Execution, First Output, Finish. A box labelled 'Job Execution' is drawn above the axis spanning from the Arrival tick to the Finish tick. Below the axis are four horizontal bars: Time1 spans Arrival to Execution; Time2 spans Execution to Finish; Time3 spans Arrival to First Output; Time4 spans Arrival to Finish.

  1. (A)

    Time1:W, Time2:R, Time3:T, Time4:S

  2. (B)

    Time1:S, Time2:W, Time3:R, Time4:T

  3. (C)

    Time1:W, Time2:R, Time3:S, Time4:T

  4. (D)

    Time1:R, Time2:S, Time3:W, Time4:T

Answer and solution
ISRO CS 2025 Q.68: answer and solution

ISRO CS 2023 Q.52

ISRO 2023 · CSQ.52 · 1 mark · MCQ

Match the Process Scheduler type with its Activity.

Process Scheduler type: (i) Long term scheduler; (ii) Medium term scheduler; (iii) Short Term Scheduler.
Activity: (P) executes much faster to reduce wastage of CPU time; (Q) controls degree of multiprogramming; (R) is associated with swapping.

With respect to Process Schedulers of an operating system mentioned above in the table, which of the following statements is correct?

ISRO CS 2023 question 52: A table with two column pairs.Tap to open full size
Figure from the ISRO CS 2023 paper. It is part of the question.
Figure description

A table with two column pairs. The left pair lists the Process Scheduler type: (i) Long term scheduler, (ii) Medium term scheduler, (iii) Short Term Scheduler. The right pair lists the Activity: (P) executes much faster to reduce wastage of CPU time, (Q) controls degree of multiprogramming, (R) is associated with swapping. The rows are printed as i/P, ii/Q, iii/R; this row alignment is only the layout, not the correct matching.

  1. (A)

    (i) - (R), (ii) - (P), (iii) - (Q)

  2. (B)

    (i) - (Q), (ii) - (R), (iii) - (P)

  3. (C)

    (i) - (P), (ii) - (R), (iii) - (Q)

  4. (D)

    (i) - (R), (ii) - (Q), (iii) - (P)

Answer and solution
ISRO CS 2023 Q.52: answer and solution

PRACTICE

6 questions to test yourself

PRACTICE 11 mark · NAT

Four processes (AT, BT in ms): P1 (0, 8), P2 (1, 4), P3 (2, 9), P4 (3, 5). They are scheduled by FCFS. Find the average waiting time in ms.

Answer and solution

Answer: (accepted range )

  1. The FCFS order is by arrival: P1, P2, P3, P4.

  2. P1 runs 0 to 8, P2 runs 8 to 12, P3 runs 12 to 21, P4 runs 21 to 26.

  3. WT = start − AT: P1 = 0, P2 = 8 − 1 = 7, P3 = 12 − 2 = 10, P4 = 21 − 3 = 18.

  4. Sum = 35, average = 35/4 = 8.75.

PRACTICE 22 marks · MSQ

Which of the following statements are TRUE? (Ignore context-switch overhead.)

  1. (A)

    SRTF gives the minimum average waiting time among all scheduling algorithms for a given set of processes with known burst times and arrival times.

  2. (B)

    Round robin with a time quantum larger than the burst of every process behaves like FCFS.

  3. (C)

    In non-preemptive priority scheduling, a newly arrived higher-priority process immediately takes the CPU from the running process.

  4. (D)

    Ageing can prevent starvation of low-priority processes.

Answer and solution

Answer: (A), (B), (D)

  1. A is true: with preemption allowed and no switch overhead, SRTF minimises the average turnaround time and hence the average waiting time.

  2. B is true: no process is ever preempted, so processes run in arrival order, as in FCFS.

  3. C is false: non-preemptive means the running process keeps the CPU until it finishes or blocks.

  4. D is true: ageing raises the priority of a process as it waits, so it eventually runs.

PRACTICE 32 marks · NAT

Round robin with time quantum 3 ms. P1, P2, P3 all arrive at time 0 in this order, with burst times 7, 4 and 2 ms. Each switch from one process to a different one takes 1 ms; there is no switch at time 0 and none after the last process finishes. Find the CPU utilisation as a percentage (to two decimal places).

Answer and solution

Answer: (accepted range )

  1. P1 runs 0 to 3 (4 left), queue [P2, P3, P1]. Switch 3 to 4.

  2. P2 runs 4 to 7 (1 left), queue [P3, P1, P2]. Switch 7 to 8.

  3. P3 runs 8 to 10 and finishes. Switch 10 to 11.

  4. P1 runs 11 to 14 (1 left), queue [P2, P1]. Switch 14 to 15.

  5. P2 runs 15 to 16 and finishes. Switch 16 to 17. P1 runs 17 to 18 and finishes.

  6. Total elapsed = 18 ms; useful work = 7 + 4 + 2 = 13 ms; utilisation = 13/18 = 0.7222 = 72.22%.

PRACTICE 42 marks · NAT

Preemptive priority scheduling, where a smaller number means higher priority. A new process preempts the running one only if its priority is strictly higher. Processes (AT, BT in ms, priority): P1 (0, 4, 3), P2 (1, 3, 1), P3 (2, 2, 2), P4 (3, 1, 1). Find the average turnaround time in ms.

Answer and solution

Answer: (accepted range )

  1. t = 0: P1 runs. At t = 1 P2 (priority 1) preempts P1, which has 3 ms left.

  2. P2 runs from 1. P3 arrives at 2 with priority 2, which is not better than 1. P4 arrives at 3 with priority 1, equal to the running P2, so there is no preemption. P2 finishes at 4.

  3. At t = 4 the ready processes are P1 (priority 3), P3 (2) and P4 (1). P4 has the best priority and runs 4 to 5.

  4. P3 runs 5 to 7. P1 runs 7 to 10.

  5. CT: P1 = 10, P2 = 4, P3 = 7, P4 = 5. TAT: 10, 3, 5, 2, sum 20.

  6. Average = 20/4 = 5.

PRACTICE 51 mark · NAT

The next CPU burst is predicted by exponential averaging with and an initial guess ms. The first three actual CPU bursts of a process are 4, 8 and 6 ms. Find the predicted length of the fourth burst, , in ms.

Answer and solution

Answer: (accepted range )

  1. .

  2. .

  3. .

PRACTICE 61 mark · MCQ

Processes (AT, BT in ms): P1 (0, 6), P2 (1, 2), P3 (2, 1), P4 (3, 3). They are scheduled by non-preemptive SJF. Which is the order of execution?

  1. (A)

    P1, P2, P3, P4

  2. (B)

    P1, P3, P2, P4

  3. (C)

    P1, P3, P4, P2

  4. (D)

    P1, P4, P3, P2

Answer and solution

Answer: (B)

  1. At t = 0 only P1 is present, and the algorithm is non-preemptive, so P1 runs 0 to 6.

  2. At t = 6 the ready processes are P2 (2), P3 (1) and P4 (3).

  3. Smallest burst first: P3 (6 to 7), then P2 (7 to 9), then P4 (9 to 12).

  4. Order: P1, P3, P2, P4.

OFFICIAL GATE 2027 SYLLABUS WORDING

Copied from the GATE 2027 syllabus; see all 2027 syllabi.

GATE CS

CPU … scheduling

Preparing in Kolkata? IAE Academy's course for GATE CSE.