The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+12 votes
2.4k views

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. 1
  2. 2
  3. 3
  4. 4
asked in Operating System by Loyal (4.3k points) | 2.4k views

2 Answers

+34 votes
Best answer

process execute in this way ...

0 ---- p1---- 10 (switching)--------p2-----30(switching)-----p3-----60 

so here only 2 switching possible (when we did not consider the starting and ending switching )

now here might be confusion that at t= 2 p1 is preempted and check that available process have shortest job time or not ...but he did not get anyone so it should not be consider as context switching ..(same happened at t=6) 

 ref :http://stackoverflow.com/questions/8997616/does-a-context-switch-occur-in-a-system-whose-ready-queue-has-only-one-process-a(thanks to anurag_s)

answer is B)

 

answered by Veteran (14.5k points)
selected by

what about OS Scheduler Process

       P1------>OS Scheduler--------->p2--------->OS scheduler--------->p3

and hence, Shouldn't there be 4 context switches?

4 in case of if we count both first and last context switching
+6 votes
Only two switches wil be required after process 1 and 2 complete.Option B.
answered by Loyal (3.3k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,705 questions
40,252 answers
114,344 comments
38,862 users