CPU Scheduling · Operating System
37 questions · asked in 24 of 27 years (2000–2026)
MCQ 24 · MSQ 2 · NAT 111-mark 21 · 2-mark 16
2000Questions per year2026
Questions 11–15 of 37
Consider the following four processes with arrival times (in milliseconds) and their length of CPU burst (in milliseconds) as shown below:
These processes are run on a single processor using preemptive Shortest Remaining Time First scheduling algorithm. If the average waiting time of the processes is 1 millisecond, then the value of Z is __________.
These processes are run on a single processor using preemptive Shortest Remaining Time First scheduling algorithm. If the average waiting time of the processes is 1 millisecond, then the value of Z is __________.
Answer: 2
Average waiting time is 1 ms for 4 processes, so the total waiting time is 4 ms. Waiting time = completion time arrival time burst time.
SRTF up to t = 4:
- P1 runs from 0 to 1 (2 ms left).
- P2 arrives at 1 with burst 1, which is less than 2, so it preempts and runs from 1 to 2. P2 waits 0.
- P1 runs from 2 to 4. P3 arrives at 3, but P1 has 1 ms left, so there is no preemption. P1 completes at 4 and waits .
At t = 4, only P3 (3 ms) and P4 (Z ms) are left. Together they must account for ms of waiting.
- If : P4 runs first (waits 0), and P3 runs after it, completing at , so it waits . Total waiting . Setting gives , which is less than 3, so it is consistent.
- If : one of them runs 4 to 4+(its burst) and the other waits for it. If P3 goes first, P3 waits 1 and P4 waits 3; if P4 goes first (Z = 3), P4 waits 0 and P3 waits 4. Either way the total is 5, not 4. So no such Z works.
Check with Z = 2: P4 runs from 4 to 6 (wait 0), P3 runs from 6 to 9 (wait ). Total ms.
Answer: 2
SRTF up to t = 4:
- P1 runs from 0 to 1 (2 ms left).
- P2 arrives at 1 with burst 1, which is less than 2, so it preempts and runs from 1 to 2. P2 waits 0.
- P1 runs from 2 to 4. P3 arrives at 3, but P1 has 1 ms left, so there is no preemption. P1 completes at 4 and waits .
At t = 4, only P3 (3 ms) and P4 (Z ms) are left. Together they must account for ms of waiting.
- If : P4 runs first (waits 0), and P3 runs after it, completing at , so it waits . Total waiting . Setting gives , which is less than 3, so it is consistent.
- If : one of them runs 4 to 4+(its burst) and the other waits for it. If P3 goes first, P3 waits 1 and P4 waits 3; if P4 goes first (Z = 3), P4 waits 0 and P3 waits 4. Either way the total is 5, not 4. So no such Z works.
Check with Z = 2: P4 runs from 4 to 6 (wait 0), P3 runs from 6 to 9 (wait ). Total ms.
Answer: 2
Consider the following CPU processes with arrival times (in milliseconds) and length of CPU burst (in milliseconds) as given below:
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes., then the average waiting time across all processes is ________ milliseconds.
If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes., then the average waiting time across all processes is ________ milliseconds.
Answer: 3
SRTF schedule: P1 runs 0-3 (4 left); P2 (3) preempts and runs 3-6; at 6: P1 4, P3 5, P4 2 P4 runs 6-8; P1 runs 8-12; P3 runs 12-17.
Waiting times: P1 = 12 0 7 = 5, P2 = 0, P3 = 17 5 5 = 7, P4 = 0 mean = 12 / 4 = 3
Answer: 3
Waiting times: P1 = 12 0 7 = 5, P2 = 0, P3 = 17 5 5 = 7, P4 = 0 mean = 12 / 4 = 3
Answer: 3
Consider the set of processes with arrival time (in milliseconds). CPU burst time (in milliseconds), and priority (0 is the highest priority) shown below. None of the processes have I/O burst time.
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is __________
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is __________
Answer: 29
Waiting time = completion time arrival time burst time. In preemptive priority scheduling (0 is highest), a newly arrived process with a higher priority takes the CPU at once.
Gantt chart: P1 0-2, P4 2-5, P2 5-33, P4 33-40, P1 40-49, P3 49-51, P5 51-67
Why the CPU changes hands:
- At t = 2, P4 (priority 1) arrives and preempts P1 (priority 2).
- At t = 5, P2 (priority 0, the highest) arrives and preempts P4. Nothing can preempt P2, so it runs to 33. P5 (priority 4) and P3 (priority 3) arrive meanwhile but must wait.
- After 33 the rest run in priority order: P4 (1), P1 (2), P3 (3), P5 (4).
Completion times: P1 49, P2 33, P3 51, P4 40, P5 67.
Waiting times:
P1 = 49 0 11 = 38
P2 = 33 5 28 = 0
P3 = 51 12 2 = 37
P4 = 40 2 10 = 28
P5 = 67 9 16 = 42
Average waiting time = (38 + 0 + 37 + 28 + 42) / 5 = 145 / 5 = 29 ms
Answer: 29 ms
Gantt chart: P1 0-2, P4 2-5, P2 5-33, P4 33-40, P1 40-49, P3 49-51, P5 51-67
Why the CPU changes hands:
- At t = 2, P4 (priority 1) arrives and preempts P1 (priority 2).
- At t = 5, P2 (priority 0, the highest) arrives and preempts P4. Nothing can preempt P2, so it runs to 33. P5 (priority 4) and P3 (priority 3) arrive meanwhile but must wait.
- After 33 the rest run in priority order: P4 (1), P1 (2), P3 (3), P5 (4).
Completion times: P1 49, P2 33, P3 51, P4 40, P5 67.
Waiting times:
P1 = 49 0 11 = 38
P2 = 33 5 28 = 0
P3 = 51 12 2 = 37
P4 = 40 2 10 = 28
P5 = 67 9 16 = 42
Average waiting time = (38 + 0 + 37 + 28 + 42) / 5 = 145 / 5 = 29 ms
Answer: 29 ms
Consider an arbitrary set of CPU-bound processes with unequal CPU burst lengths submitted at the same time to a computer system.Which one of the following process scheduling algorithms would minimize the average waiting time in the ready queue?
Answer: (A)
All the processes come at the same time. So shortest remaining time first works just like SJF, and SJF is optimal for average waiting time. With round robin, random order or "long jobs first", the short jobs have to wait more.
Answer: Shortest remaining time first
Answer: Shortest remaining time first
Consider the following processes, with the arrival time and the length of the CPU burst given in milli seconds.The scheduling algorithm used is preemptive shortest remaining-time first.
The average turn around time of these processes is milliseconds.
The average turn around time of these processes is milliseconds.
Answer: 8.2 to 8.3
SRTF: P1 runs 0-3 (7 left). P2 arrives (6 7) and runs 3-7 (2 left). P3 (1) runs 7-8. P2 runs 8-10. P4 runs 10-13. P1 runs 13-20.
Turnaround: P1 is 20, P2 is 10 3 = 7, P3 is 8 7 = 1, P4 is 13 8 = 5.
Average = 33 / 4 = 8.25
Answer: 8.25
Turnaround: P1 is 20, P2 is 10 3 = 7, P3 is 8 7 = 1, P4 is 13 8 = 5.
Average = 33 / 4 = 8.25
Answer: 8.25
Keep practising
Topics in Operating System
System CallProcessThreadProcess SynchronizationDeadlock
CPU SchedulingYou are here
Disk SchedulingMemory ManagementFile Systems