Average wait time in planning Round Robin

Wait time is defined as the time during which each process must wait before it receives its time slice. In scheduling algorithms such as Shorted Job First and First Come First Serve, we can easily find this waiting time, when we simply queue for work and see how long each of them had to wait before it was serviced.

When it comes to Round Robin or any other proactive algorithms, we find that lengthy work tasks spend a little time on the processor when they are unloaded, and then someday wait for it to turn on, and at some point it turns around, it runs to completion. I wanted to find a better way to understand the “waiting time” for jobs in such a scheduling algorithm.

I found a formula that gives a wait time like:

Waiting Time = (Final Start Time - Previous Time in CPU - Arrival Time) 

But I do not understand the reasons for this formula. E.g. Consider work A, which has a time unit of 30 units and a circular motion occurs every 5 units. There are two more tasks B (10) and C (15).

The order in which they will be served will be:

 0 A 5 B 10 C 15 A 20 B 25 C 30 A 35 C 40 A 45 A 50 A 55 

Waiting time for A = 40 - 5 - 0

  • I choose 40 because after 40 A never waits. He simply receives his time fragments and continues and continues.
  • Choose 5 because the spent in the process prevails between 30 and 35.
  • 0 - start time.

Well, I doubt this formula, why why 15 A 20 not taken into account? Intuitively, I cannot understand how this gives us the wait time for A, when we simply take into account the penultimate execution, and then subtract the arrival time.

For me, the wait time for A should be:

  • The final start time is (the sum of all the processing time spent).

If this formula is incorrect, why?

Please help clarify my understanding of this concept.

+6
algorithm operating-system
source share
2 answers

You misunderstood what the formula "previous time in the CPU" means. This actually means the same thing that you call "the sum of all the time spent on processing." (I think that “previous CPU time” should be short for “total time spent starting up the CPU,” where “earlier” means “until the final run”.)

You still need to subtract the time of arrival, because the process obviously did not wait until it arrived. (Just in case, this is unclear: “Arrival time” is the time when the task was sent to the scheduler.) In your example, the arrival time for all processes is 0, so this does not matter, but in general it is necessary to take into account the arrival time.

Edit: if you look at the example on the web page that you linked to, the process P1 takes two time fragments of four time units each before its final launch, and its “previous time on the CPU” is calculated as 8, according to the interpretation above .

+5
source share

Last wait

value- (time slice × (n-1))

Here n denotes the number of times a process arrives in a gantt diagram.

0
source share

All Articles