1,170 views
1 votes
1 votes

A context switch from a process $P_{old}$ to a process $P_{new}$ consists of the following steps:

  1. Step I:saving the context of $P_{old}$;
  2. Step II: running the scheduling algorithm to pick $P_{new}$;
  3. Step III: restoring the saved context of $P_{new}$.

Suppose Steps I and III together take $T_0$ units of time. The scheduling algorithm takes $nT_1$ units of time, where $n$ is the number of ready-to-run processes. The scheduling policy is round-robin with a time slice of $10$ms. Compute the CPU utilization for the following scenario: $k$ processes become ready at almost the same instant in the order $P_1, P_2, . . . , P_k;$ each process requires exactly one CPU burst of $20$ms and no I/O burst.

2 Answers

2 votes
2 votes

Few points to keep in mind.

  • When process is scheduled first Step 3 not required.
  • When process is scheduled for last time step 1 not required.

Ref: https://cs.stackexchange.com/questions/74049/does-a-context-switch-happen-when-a-process-has-terminated

 

Total time used for process = 2 * k * 10 (Each process is gets 2 time slice of 10 ms.)

In 1st cycle it takes  $kT_{1}$ for selecting which process to schedule and $T_{0}$ for saving the context.

In 2nd cycle it takes  $kT_{1}$ for selecting which process to schedule and $T_{0}$ for restoring the context.

Total Time =  $2 * k * 10 +  2k (kT_{1} + T_{0} )$ 

$CPU$ $Utitlization =$ $\frac{ Useful Work}{Total Time}$

                                =  $\frac{ 2 * k * 10}{2 k(kT_{1} + T_{0} ) + 2 * k * 10 }$

                                =  $\frac{ 10k}{ k^2T_{1} + kT_{0}  + 10k }$

0 votes
0 votes

CPU Utilization = 10*k / [10*k + k*(T0 + k*T1)]

Related questions

1 votes
1 votes
2 answers
1
akash.dinkar12 asked May 12, 2019
1,270 views
Consider a $5$-stage instruction pipeline. The stages and the corresponding stage delays are given below.$$\begin{array}{|l|l|}\hline \textbf{Instruction}&\textbf{Stage d...
1 votes
1 votes
3 answers
2