##### Context switching

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

a. 1            b. 2               c.3               d.4

create gantt chart

 A B C

0                                 10                                 30                                  60

Therr is two context switches at the time unit 10(between A to B) and at the time unit 30(between B to C).so ans is b.

##### 1Comment
Mohit Lalwani
27 Jun 2016 08:36 pm

arrive time  |  execution  time
p1      0           |          10

p2      2           |          20

p3      6           |          30

Gantt chart:

|___p1_____|____p2_____|____p3____|
0                 10                   30                60
context  switch means turn another process;
given not count the context switches at the time zero and at the end:
2 context switches occur one is p1 to p2 and p2 to p3;