Consider three CPU-intensive processes, which require 10, 20 and 30 time units…

2009

Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    4

Attempted by 180 students.

Show answer & explanation

Correct answer: B

In Shortest Remaining Time First (SRTF), the process with the least remaining burst time runs. At t=0, P1 starts (burst 10). At t=2 and t=6, P2 and P3 arrive, but P1's remaining time (8 then 4) is less than both. At t=10, P1 completes (Context Switch 1). Between remaining P2 (burst 20) and P3 (burst 30), P2 runs next. At t=30, P2 completes (Context Switch 2). Finally, P3 runs to completion. Excluding start and end switches, there are exactly 2 context switches.

Explore the full course: Isro