409 views

### For example, with five processes and a time quantum of 20 milliseconds, each process will get up to 20 milliseconds every 100 milliseconds.

Can someone please explain this in a simple way, I'm not getting how each process will get 20 milliseconds every 100 ms?

| 409 views

Brother, they are talking about round robbin algorithm, where time quantum ='q' sec.

if you have n processes in ready queue with each have large burst time, the ready queue look like as : P1,P2,...Pn

now, if you run P1....how much time it will run? it should be 'q' sec, but it is not completed

now analyze, next time P1 should run when after running of P2,P3,...Pn ====> Each process must wait no longer than (n − 1) × q time units its next time quantum.

what is the meaning of each process gets 1/n of the CPU time in chunks of at most q time units. ?

therefore in the time of n * q sec, each process can get only $\frac{1}{n}$ * q sec only.

for you example, 5 processes... P1,P2,P3,P4,P5 with tq=20 msec and assume every process requires more than 20 msec

P1
0->20 ( after 20 sec P1 looses its turn )

P1 P2
0->20 20->40

P1 P2 P3
0->20 20->40 40->60

P1 P2 P3 P4
0->20 20->40 40->60 60->80

P1 P2 P3 P4 P5
0->20 20->40 40->60 60->80 80->100

Ready Queue:- P1,P2,P3,P4,P5 ==> ready queue is now look like as initial ==> P1 got its turn again after 80 msec => (n-1)*q

P1 P2 P3 P4 P5
0->20 20->40 40->60 60->80 80->100

total of 100 msec, each process get only 20 msec ==> therefore in the time of n * q sec, each process can get only $\frac{1}{n}$ * q sec only.

by Veteran (65.7k points)
selected by
0

@ Shaik Masthan  Thank you so much brother for explaining it very simple and for all the effort and time you put in, Thanks!