edited by
15,210 views
33 33 votes

An operating system uses shortest remaining time first scheduling algorithm for pre-emptive scheduling of processes. Consider the following set of processes with their arrival times and CPU burst times (in milliseconds):$$\small \begin{array}{|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time} & \textbf{Burst Time}\\\hline \text{P1} & 0 & 12 \\ \text{P2} & 2 & 4  \\ \text{P3} & 3 & 6 \\ \text{P4} & 8 & 5 \\\hline   \end{array}$$The average waiting time (in milliseconds) of the processes is ______.

4 Answers

Best answer
42 42 votes
Gantt Chart

$$\small \begin{array}{|c|c|c|c|c|c|} \hline \textbf{Process} & \textbf{Arrival } & \textbf{Burst} & \textbf{Completion} & \textbf{Turn Around} & \textbf{Waiting Time} \\
& \textbf{Time} & \textbf{Time} & \textbf{Time} & \textbf{Time} & \textbf{= CT - BT -AT} \\
\hline
\text{P1} & 0 & 12 & 27 & 27 & 15 \\ \text{P2} & 2 & 4 & 6 & 4 & 0 \\ \text{P3} & 3 & 6 & 12 & 9 & 3 \\ \text{P4} & 8 & 5 & 17 & 9 & 4 \\\hline   \end{array}$$Average Waiting Time $=(15 + 0 + 3 + 4)/4 = 5.5$ msec

edited by
2 2 votes
Process   Arrival Time   Burst Time
  P1           0           12
  P2           2           4
  P3           3           6
  P4           8           5 

Burst Time - The total time needed by a process from the CPU for its complete execution. Waiting Time - How much time processes spend in the ready queue waiting their turn to get on the CPU Now, The Gantt chart for the above processes is :

P1 - 0 to 2 milliseconds

P2 - 2 to 6 milliseconds

P3 - 6 to 12 milliseconds

P4 - 12 to 17 milliseconds

P1 - 17 to 27 milliseconds 

Process p1 arrived at time 0, hence cpu started executing it. After 2 units of time P2 arrives and burst time of P2 was 4 units, and the remaining time of the process p1 was 10 units,hence cpu started executing P2, putting P1 in waiting state(Pre-emptive and Shortest remaining time first scheduling). Due to P1's highest remaining time it was executed by the cpu in the end.

Now calculating the waiting time of each process:
P1 -> 17 -2 = 15
P2 -> 0
P3 -> 6 - 3 = 3
P4 -> 12 - 8 = 4 

Hence total waiting time of all the processes is 
                                     = 15+0+3+4=22
Total no of processes = 4
Average waiting time = 22 / 4 = 5.5
Hence C is the answer.
Answer:
Position:
Show:

Related questions

9 9 votes
5 answers 5 answers
8.9k
8.9k views
go_editor asked Sep 28, 2014
8,853 views
In the context of modular software design, which one of the following combinations is desirable?High cohesion and high couplingHigh cohesion and low couplingLow cohesion ...
60 60 votes
5 answers 5 answers
24.9k
24.9k views
go_editor asked Sep 28, 2014
24,907 views
Consider a paging hardware with a $TLB$. Assume that the entire page table and all the pages are in the physical memory. It takes $10$ milliseconds to search the $TLB$ an...
26 26 votes
2 answers 2 answers
11.9k
11.9k views
go_editor asked Sep 28, 2014
11,886 views
A system uses $3$ page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are...
71 71 votes
6 answers 6 answers
23.0k
23.0k views
go_editor asked Sep 28, 2014
22,994 views
Three processes $A$, $B$ and $C$ each execute a loop of $100$ iterations. In each iteration of the loop, a process performs a single computation that requires $t_c$ CPU m...