edited by
3,725 views
5 votes
5 votes

Consider three CPU intensive processes, which require $10$, $20$ and $30$ units of time 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. $4$
  2. $2$
  3. $3$
  4. $1$
edited by

5 Answers

2 votes
2 votes

$$\overset{\text{Process}}{\begin{array}{|c|c|c|}\hline\\
\textbf{process}&  \textbf{Arrival Time}& \textbf{Burst time} \\\hline
P_1&     \text{0}&    10  \\ \hline   
P_2&     \text{2}& 20 \\     \hline
P_3&     \text{6}&  30     \\\hline
\end{array}}$$

Shortest remaining time first :- Select the process with the smallest amount of remaining time among all the process to execute first.

So here we will $1^{st}$ select $P_1$ then $P_2$ and at last $P_3$.

It is mentioned in question

Do not count the context switches at time zero and at the end

So, we will have take only $2$ context switch into account i.e. $P_1$ to $P_2$ and $P_2$ to $P_3$.

$\therefore$ Option $B.$  $2$ is the correct answer.

Answer:

Related questions

1 votes
1 votes
1 answer
1
3 votes
3 votes
3 answers
3
Arjun asked Jul 2, 2019
1,863 views
Match List-I with List-II:$$\begin{array}{|c|c|c|c|} \hline {}& \text{List-I} & {} & \text{List-II} \\ \hline (a) & \text{Disk} & (i) & \text{Thread} \\ \hline (b) & \te...