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 16–20 of 37
Consider a uniprocessor system executing three tasks T1, T2 and T3, each of which is composed of an infinite sequence of jobs (or instances) which arrive periodically at intervals of 3, 7 and 20 milliseconds, respectively. The priority of each task is the inverse of its period, and the available tasks are scheduled in order of priority, with the highest priority task scheduled first. Each instance of T1, T2 and T3 requires an execution time of 1, 2 and 4 milliseconds, respectively. Given that all tasks initially arrive at the beginning of the 1st millisecond and task preemptions are allowed, the first instance of T3 completes its execution at the end of _____________ milliseconds.
Answer: 12
Order of priority: T1 (period 3) T2 (period 7) T3 (period 20).
Schedule:
0-1: T1 runs. 1-3: T2 runs. 3-4: T1 runs (new instance).
4-6: T3 runs (2 of its 4 ms).
6-7: T1 runs. 7-9: T2 runs. 9-10: T1 runs.
10-12: T3 runs (the remaining 2 ms) it finishes.
Answer: 12
Schedule:
0-1: T1 runs. 1-3: T2 runs. 3-4: T1 runs (new instance).
4-6: T3 runs (2 of its 4 ms).
6-7: T1 runs. 7-9: T2 runs. 9-10: T1 runs.
10-12: T3 runs (the remaining 2 ms) it finishes.
Answer: 12
For the processes listed in the following table, which of the following scheduling schemes will give the lowest average turnaround time?
Answer: (C)
Turnaround time = completion time arrival time. Arrivals of A, B, C, D are 0, 1, 4, 6 and processing times are 3, 6, 4, 2.
- FCFS: A runs 0-3, B 3-9, C 9-13, D 13-15 (3 + 8 + 9 + 9)/4 = 7.25
- Non-preemptive SJF: A runs 0-3. At 3 only B is waiting, so B runs 3-9. At 9, D (2) is shorter than C (4), so the order is A, B, D, C, completing at 3, 9, 11, 15 (3 + 8 + 5 + 11)/4 = 6.75
- SRT: A runs 0-3 and B 3-4. At 4, C (4) arrives and is shorter than B's remaining 5, so C preempts B and runs 4-8. At 6, D (2) arrives, but C also has 2 left, so C keeps running. Then D runs 8-10 and B 10-15 (3 + 14 + 4 + 4)/4 = 6.25
- RR (q = 2): A 0-2, B 2-4, A 4-5, C 5-7, B 7-9, D 9-11, C 11-13, B 13-15. Here a process that arrives just as a quantum ends is queued before the preempted one. Turnaround times are A 5, B 14, C 9, D 5 (5 + 14 + 9 + 5)/4 = 8.25
SRT has the lowest average (6.25), because it always runs the process with the least work left, so short processes do not wait behind long ones.
Answer: (C)
- FCFS: A runs 0-3, B 3-9, C 9-13, D 13-15 (3 + 8 + 9 + 9)/4 = 7.25
- Non-preemptive SJF: A runs 0-3. At 3 only B is waiting, so B runs 3-9. At 9, D (2) is shorter than C (4), so the order is A, B, D, C, completing at 3, 9, 11, 15 (3 + 8 + 5 + 11)/4 = 6.75
- SRT: A runs 0-3 and B 3-4. At 4, C (4) arrives and is shorter than B's remaining 5, so C preempts B and runs 4-8. At 6, D (2) arrives, but C also has 2 left, so C keeps running. Then D runs 8-10 and B 10-15 (3 + 14 + 4 + 4)/4 = 6.25
- RR (q = 2): A 0-2, B 2-4, A 4-5, C 5-7, B 7-9, D 9-11, C 11-13, B 13-15. Here a process that arrives just as a quantum ends is queued before the preempted one. Turnaround times are A 5, B 14, C 9, D 5 (5 + 14 + 9 + 5)/4 = 8.25
SRT has the lowest average (6.25), because it always runs the process with the least work left, so short processes do not wait behind long ones.
Answer: (C)
Consider the following set of processes that need to be scheduled on a single CPU. All the times are given in milliseconds
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ________.
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ________.
Answer: 7.2
SRTF always runs the process with the shortest remaining time, checked whenever a process arrives or finishes.
- t = 0-3: only A is present, so A runs (3 left).
- t = 3: B arrives with 2, which is less than A's 3, so B preempts A and runs 3-5.
- t = 5: B is done. C arrives with 4, but A has only 3 left, so A runs 5-8. D arrives at 7 with 6, which is more than A's 1 left, so there is no change.
- t = 8: A is done. C (4) is shorter than D (6), so C runs from 8. E arrives at 10 with 3, but C has only 2 left, so C is not preempted and finishes at 12.
- t = 12: E (3) is shorter than D (6), so E runs 12-15. Then D runs 15-21.
Schedule: A 0-3, B 3-5, A 5-8, C 8-12, E 12-15, D 15-21.
Turnaround time = completion arrival:
A = 8 0 = 8, B = 5 3 = 2, C = 12 5 = 7, D = 21 7 = 14, E = 15 10 = 5
Average = (8 + 2 + 7 + 14 + 5) / 5 = 36 / 5 = 7.2 ms
Answer: 7.2 ms
- t = 0-3: only A is present, so A runs (3 left).
- t = 3: B arrives with 2, which is less than A's 3, so B preempts A and runs 3-5.
- t = 5: B is done. C arrives with 4, but A has only 3 left, so A runs 5-8. D arrives at 7 with 6, which is more than A's 1 left, so there is no change.
- t = 8: A is done. C (4) is shorter than D (6), so C runs from 8. E arrives at 10 with 3, but C has only 2 left, so C is not preempted and finishes at 12.
- t = 12: E (3) is shorter than D (6), so E runs 12-15. Then D runs 15-21.
Schedule: A 0-3, B 3-5, A 5-8, C 8-12, E 12-15, D 15-21.
Turnaround time = completion arrival:
A = 8 0 = 8, B = 5 3 = 2, C = 12 5 = 7, D = 21 7 = 14, E = 15 10 = 5
Average = (8 + 2 + 7 + 14 + 5) / 5 = 36 / 5 = 7.2 ms
Answer: 7.2 ms
Three processes A, B and C each execute a loop of 100 iterations. In each iteration of the loop, a process performs a single computation that requires CPU milliseconds and then initiates a single I/O operation that lasts for milliseconds. It is assumed that the computer where the processes execute has sufficient number of I/O devices and the OS of the computer assigns different I/O devices to each process. Also, the scheduling overhead of the OS is negligible. The processes have the following characteristics:
The processes A, B, and C are started at times 0, 5 and 10 milliseconds respectively, in a pure time sharing system (round robin scheduling) that uses a time slice of 50 milliseconds. The time in milliseconds at which process C would complete its first I/O operation is ___________.
The processes A, B, and C are started at times 0, 5 and 10 milliseconds respectively, in a pure time sharing system (round robin scheduling) that uses a time slice of 50 milliseconds. The time in milliseconds at which process C would complete its first I/O operation is ___________.
Answer: 1000
Round robin, quantum 50 ms. CPU needed before the first I/O: A 100, B 350, C 200.
- 0-50 A, 50-100 B, 100-150 C, 150-200 A (A finishes, goes to I/O)
- 200-250 B, 250-300 C, 300-350 B, 350-400 C
- 400-450 B, 450-500 C (C has had 200 ms)
C begins I/O at 500 and ends it at 500 + 500 = 1000 ms.
Answer: 1000
- 0-50 A, 50-100 B, 100-150 C, 150-200 A (A finishes, goes to I/O)
- 200-250 B, 250-300 C, 300-350 B, 350-400 C
- 400-450 B, 450-500 C (C has had 200 ms)
C begins I/O at 500 and ends it at 500 + 500 = 1000 ms.
Answer: 1000
An operating system uses shortest remaining time first scheduling algorithm for pre-emptive scheduling of processes. Consider the following set of processes with their arrival times and CPU burst times (in milliseconds):
The average waiting time (in milliseconds) of the processes is _________.
The average waiting time (in milliseconds) of the processes is _________.
Answer: 5.5
SRTF schedule:
- 0-2: P1 runs (remaining 10)
- 2-6: P2 runs (P3 comes at 3 and needs 6, which is more than what P2 has left)
- 6-12: P3 runs (P4 comes at 8 and needs 5, which is more than the 4 P3 has left)
- 12-17: P4 runs, then 17-27: P1 runs
Waiting time = completion time arrival time burst time:
P1 = 27 0 12 = 15, P2 = 0, P3 = 12 3 6 = 3, P4 = 17 8 5 = 4
Average = 22 / 4 = 5.5
Answer: 5.5
- 0-2: P1 runs (remaining 10)
- 2-6: P2 runs (P3 comes at 3 and needs 6, which is more than what P2 has left)
- 6-12: P3 runs (P4 comes at 8 and needs 5, which is more than the 4 P3 has left)
- 12-17: P4 runs, then 17-27: P1 runs
Waiting time = completion time arrival time burst time:
P1 = 27 0 12 = 15, P2 = 0, P3 = 12 3 6 = 3, P4 = 17 8 5 = 4
Average = 22 / 4 = 5.5
Answer: 5.5
Keep practising
Topics in Operating System
System CallProcessThreadProcess SynchronizationDeadlock
CPU SchedulingYou are here
Disk SchedulingMemory ManagementFile Systems