edited by
4,833 views
14 votes
14 votes

i am getting answer as 6....to calculate waiting time i have removed CPU time used by the process (BT) from total time spend inside(TAT)....not included I/O time(i think I/O is also included in waiting time)..is it correct?

Three processors P,Q,R are started at times 0 ,2 ,3 milliseconds respectively. Each of the process performs a computation that required TC1 CPU milliseconds then initiates a single I/O operation that lasts for TIO milliseconds and at the last it again performs a computation that required TC2 CPU milliseconds. It is assumed that the processes execute has sufficient number of I/O devices and the OS of the computer assigns different I/O devices to each process . Also scheduling overhead of the OS is negligible. The processes have the following characteristics :

Process Arrival Time Priority TC1 TIO TC2
   P      0     2    1    5   3
   Q      2     3(L)    3    3   1
   R      3     1(H)    2    3   1

What is the average waiting time (in milliseconds) ?

edited by

5 Answers

Best answer
14 votes
14 votes

Answer is.  2.33 ms

Waiting Time of a process is the time spend by it in READY queue only

WT = total TAT - ( CPU + IO )
 

   TAT IO CPU WT
P     10   4     5   1
Q     13   4     3   6
R      6   3     3    0

Avg Waiting TIme =$\frac{1+6+0}{3} = 2.33 $ms



Some useful EDIT :--> 

Time spent for waiting for the CPU is known as waiting time . 

But, In a system running a single process, the time spent waiting for I/O is wasted, and those CPU cycles are lost forever.

The time spent for I/O is also known as waiting time for a system running only a single process, because that CPU cycles are lost in that wait .

But What happens for multiprocessing system ? Now, this is why we use multiprocessing systems in which processes waiting in READY queue, are actually waiting for CPU which is waiting time .

But what about waiting for I/O ? isn't that also waiting time. Yes, for a single process system.

But for a multiprocessor system,i.e, A scheduling system allows one process to use the CPU while another is waiting for I/O, thereby making full use of lost CPU cycles ,hence, process which was waiting in single process system for I/O made lose of CPU cycles, which is now covered by the other process which is dispatched by the dispatcher to cover the losses .

Moreover, 

It is assumed in the questíon, that processes execute has sufficient number of I/O devices and the OS of the computer assigns different I/O devices to each process , hence, there is no waiting time for a process blocked under I/O . Even if it was, it is covered by scheduling other processes.

edited by
10 votes
10 votes

Here the Gantt Chart looks like $\Rightarrow$

Completion time of $P,Q$ and $R$ are $10,15$ and $9$ respectively.

Earlier I computed average waiting time as $\Rightarrow$

And Waiting time  = Completion time - Arrival time - Burst time

$WT = (10+15+9) - (0 + 2+3) - (4 + 4+ 3) = 18$

So, average waiting time $ = \frac{18}{3} = 6$

But after messaging many users and reading many links final conclusion is that : I/O time is not considered as waiting time.  and Waiting time for a process is the  time for which the process waits in ready queue for CPU to be available.


So, total waiting time = Completion time - Arrival time - Burst time - I/O time

 $WT = (10+15+9) - (0 + 2+3) - (4 + 4+ 3) - (5 + 3 +3) = 7$

average waiting time $ = \frac{7}{3} = 2.333$


And also from Gantt Chart, waiting time for $P = ( 9 - 8) = 1$

Waiting time for $Q = (5 - 3) + (10 - 6) = 6$

Waiting time for $R = 0$

Average Waiting time $= \frac{1 + 6 +0}{3} = 2.333$

edited by
4 votes
4 votes

Yes answer should be   6.

A process is doing I/O operation cant be  considerd as idle or in a waiting state.

the process can be scheduled as follows::

P ** Q R Q P R P Q ** Q

0         1  I/O   2        3          5          6         8          9        10        11 I/O  14       15

waiting time (TAT- BT ) of A is 10-4=6

waiting time of B is  13-4=9

waiting time of C  is 6-3 = 3.

Avg. waiting time  is 6.

2 votes
2 votes

Refer the above gant chart of the given scheduling.

Wp (Waiting time for P) = 1 mS (between 8 to 9 mS)
WQ (Waiting time for P) = 2 mS (between 3 to 5 mS) + 4 mS (between 6 to 10 mS)
WQ (Waiting time for P) = 0 (No waiting)

Hence Avg Waiting time = 7/3 = 2.33 mS

NOTE: Waiting time for a process would be the time for which the process is waiting in ready queue for CPU to be available. Hence, I/O time will never be considered in waiting time as process is not waiting for CPU. Even if the CPU is available the process could not use it because it busy doing I/O.  (reference OS galvin scheduling criteria section)   -----> this is the correct solution of the above problem done by pritam sir , techtud       

Related questions

0 votes
0 votes
0 answers
3
roopkathaaa asked Aug 30, 2023
355 views
Let the base priority of a system be 130 and the nice value provided is -10. What is the time slice that the process gets in the O(1) scheduling algorithm?if it should be...
0 votes
0 votes
1 answer
4