ISRO Computer Science (CSE) 2009 - Question 14

All ISRO Computer Science (CSE) papers | ISRO Computer Science (CSE) 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.

  • A. 1
  • B. 2
  • C. 3
  • D. 4

Answer: B. 2

Explanation: P1(10), P2(20), P3(30). Arrivals 0, 2, 6. \nT=0: P1 starts. \nT=2: P1 rem=8, P2=20. P1 continues. \nT=6: P1 rem=4, P2=20, P3=30. P1 continues. \nT=10: P1 ends. Switch to P2. (Context Switch 1). \nT=30: P2 ends. Switch to P3. (Context Switch 2). \nT=60: P3 ends. \nTotal switches = 2.

| | All questions of ISRO Computer Science (CSE) 2009