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

2017

Consider three CPU intensive processes, which require 10, 20, 30 units and arrive at times 0, 2, 6 respectively. How many context switches are needed if shortest remaining time first is implemented? Context switch at 0 is included but context switch at end is ignored

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    4

Attempted by 242 students.

Show answer & explanation

Correct answer: C

At t=0, P1 arrives (burst 10). Context switch #1 occurs to load P1. At t=2, P2 arrives (burst 20). Remaining time of P1 is 8. Since 8 < 20, no preemption occurs. At t=6, P3 arrives (burst 30). Remaining time of P1 is 4. Since 4 < 30, no preemption occurs. At t=10, P1 completes. Context switch #2 occurs to load P2 (burst 20). At t=30, P2 completes. Context switch #3 occurs to load P3 (burst 30). At t=60, P3 completes. Total context switches = 3.

Explore the full course: Isro