189 views
3 3 votes

A system has two processes, $P_1$ and $P_2$.

  • $P_1$ is currently running.
     
  • $P_2$ is ready.
     
  • The operating system uses preemptive Round Robin scheduling.
     
  • $P_1$'s scheduling quantum is about to expire.
     
  • $P_2$ will be selected to run next.
     

Consider the following events:

  1. $P_1$'s user-level state is saved into a trap frame.
     
  2. $P_2$'s user-level state is saved into a trap frame.
     
  3. A timer interrupt occurs.
     
  4. The operating system scheduler runs.
     
  5. A context switch occurs from the thread of $P_1$ to the thread of $P_2$.
     
  6. $P_1$'s user-level state is restored.
     
  7. $P_2$'s user-level state is restored.
     
  8. A system-call instruction is executed.
     
  9. The thread of $P_2$ is created.
     
  10. The thread of $P_1$ is destroyed.
     

Which sequence correctly describes the events?

  1. $3,1,4,5,7$
     
  2. $3,4,1,7,5$
     
  3. $1,3,5,4,7$
     
  4. $3,1,5,4,6$

1 Answer

0 0 votes

Initially, $P_1$ is running and $P_2$ is ready.

When the time quantum of $P_1$ expires, the following events occur in order:

First, the timer generates an interrupt.

$3.$ Timer interrupt occurs.


The current user-level state of $P_1$ must then be saved so that $P_1$ can resume later.

$1.$ $P_1$'s user-level state is saved into a trap frame.


The operating system scheduler now runs and selects the next process.

$4.$ The operating system scheduler runs.


Since $P_2$ is selected, a context switch occurs from $P_1$ to $P_2$.

$5.$ Context switch from $P_1$ to $P_2$.


Finally, the saved user-level state of $P_2$ is restored so that it can resume execution.

$7.$ $P_2$'s user-level state is restored.


 

Therefore, the correct sequence is:

$3 \rightarrow 1 \rightarrow 4 \rightarrow 5 \rightarrow 7$


Answer : A

Answer:
Position:
Show:

Related questions

4 4 votes
2 2 answers
165
165 views
GO Classes asked Jul 21
165 views
Consider the following workload:$$\begin{array}{c|c|c} \text{Job} & \text{Arrival Time} & \text{CPU Burst Time} \\ \hline A & 0 & 8 \\ B & 2 & 4 \\ C & 5 & 7 \end{array}$...
1 1 vote
1 1 answer
162
162 views
GO Classes asked Jul 21
162 views
Which of the following statements are true about a scheduler that implements a Round Robin scheduling policy?This scheduler will minimize the number of context switches w...
0 0 votes
1 1 answer
2.6k
2.6k views
anupamsworld asked Jun 6, 2022
2,616 views
Lets consider one situation where,OS is scheduling processes(P1,P2,P3...Pn) with Round Robin method and current running process is P1 and next scheduled process in queue ...
3 3 votes
3 3 answers
241
241 views
GO Classes asked Jul 23
241 views
$4$ processes $A,B,C,D$ have estimated burst times of $4,~5,~6,~7$ $\text{ns}$ respectively. They are scheduled in round robin fashion and the time slice is of $2$ $\text...