Consider the Processes, Arrival time and their Burst time as given below: Process Arrival...
Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Consider the Processes, Arrival time and their Burst time as given below:
| Process | Arrival Time | Burst Time |
|---|---|---|
| P1 | 0 | 9 |
| P2 | 1 | 3 |
| P3 | 2 | 8 |
| P4 | 3 | 5 |
What will be the order of the processes that has finished executing first with respect to the SRTF scheduling algorithm?
Show answer & explanation
SRTF (Shortest Remaining Time First) is a preemptive CPU scheduling algorithm that always executes the process with the smallest remaining burst time. At each scheduling point, we select the arrived process with the shortest remaining time. Following the timeline: P1 runs until P2 arrives (time 1), then P2 (3ms) preempts P1. After P2 finishes, P4 arrives and runs next (5ms). Then P1 resumes (6ms remaining), and finally P3 executes (8ms). The completion order is P2, P4, P1, P3.
Step-by-step Derivation:
Timeline using SRTF:
Time 0-1: P1 runs (burst=9, remaining=8 at t=1)
Time 1: P2 arrives (burst=3) → P2 has shorter burst, preempt P1
Time 1-4: P2 runs (burst=3) → P2 completes (FIRST: P2)
Time 4: P3 arrives (burst=8), P1 has remaining=8
Time 4-5: Continue evaluating: P4 arrives at time 3, so P4 is available with burst=5
Time 4: P4 (remaining=5) vs P1 (remaining=8) → P4 has shorter burst
Time 4-9: P4 runs (burst=5) → P4 completes (SECOND: P4)
Time 9: P1 (remaining=8) vs P3 (remaining=8) → Both equal, process by arrival order
Time 9-17: P1 runs (burst=8) → P1 completes (THIRD: P1)
Time 17-25: P3 runs (burst=8) → P3 completes (FOURTH: P3)
Completion Order: P2, P4, P1, P3