GATE CS 2024 Set 2 — Question 37
MCQ+2 / -0.67MediumFCFS & SJFProcess SchedulingOperating SystemSRTF (Preemptive SJF)Scheduling Numericals
Operating System → Process Scheduling → FCFS & SJF
Last updated
Question
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?
A.
SRTF = 6, NP-SJF = 7
B.
SRTF = 6, NP-SJF = 7.5
C.
SRTF = 7, NP-SJF = 7.5
D.
SRTF = 7, NP-SJF = 8.5
Correct answer
(B) SRTF = 6, NP-SJF = 7.5
Solution
We calculate the average waiting time for both algorithms.1. Preemptive Shortest Remaining Time First (SRTF):Processes: A(0, 10), B(2, 6), C(4, 3), D(6, 7)
- t=0: A arrives (burst 10). A starts.
- t=2: B arrives (burst 6). A has run for 2 units, remaining 8. B(6) < A(8), so preempt A. B starts.
- t=4: C arrives (burst 3). B has run for 2 units, remaining 4. C(3) < B(4), so preempt B. C starts.
- t=6: D arrives (burst 7). C has run for 2 units, remaining 1. C(1) < D(7), so continue C.
- t=7: C finishes. Remaining: A(8), B(4), D(7). Shortest is B(4). B resumes.
- t=11: B finishes. Remaining: A(8), D(7). Shortest is D(7). D starts.
- t=18: D finishes. Remaining: A(8). A resumes.
- t=26: A finishes.
- C: 7
- B: 11
- D: 18
- A: 26
- A:
- B:
- C:
- D:
- A:
- B:
- C:
- D:
- t=0: A arrives. Only A is available. A starts.
- t=10: A finishes. Available processes: B(2, 6), C(4, 3), D(6, 7). Shortest is C(3). C starts.
- t=13: C finishes. Available: B(2, 6), D(6, 7). Shortest is B(6). B starts.
- t=19: B finishes. Available: D(6, 7). D starts.
- t=26: D finishes.
- A: 10
- C: 13
- B: 19
- D: 26
- A:
- B:
- C:
- D:
- A:
- B:
- C:
- D:
More questions on Process Scheduling
2024 Set 1 Q24Which of the following statements about threads is/are TRUE?2024 Set 2 Q24Which of the following tasks is/are the responsibility/responsibilities of the memory management…2024 Set 2 Q25Consider a process P running on a CPU. Which one or more of the following events will always…2024 Set 1 Q25Which of the following process state transitions is/are NOT possible?2024 Set 1 Q40Consider the following two threads T1 and T2 that update two shared variables a and b. Assume that…
Practice GATE CS PYQs with adaptive difficulty
Timed practice, skill tracking, and AI explanations — free to start.
Start practicing free