Search code examples
schedulinground-robin

Round robin worst case response time


The pseudo-codes below shows a typical Round Robin software architecture. If every device requires 20ms to service and UpdateLCD() requires 10ms to execute, what is the worst case response time?

void main (void) {
   while(1) {
     if (!! Device A needs Service) { 
         !! Handle Device A
     }

     if (!! Device B needs Service) {
         !! Handle Device B
     }

     . . . .

     if (!! Device D needs Service) {
         !! Handle Device D
     }

     UpdateLCD();
   }
}

Since there are a total of 4 devices (A,B,C,D) and if immediately after servicing Device A, Device A needs servicing, the worst case response time here should be 20+20+20+10 = 70ms (assuming Devices B, C and D also needs servicing).

However, in the answer selection, there is only: 85ms, 110ms, 35ms and 25ms. I think i need help on my understanding of the round robin architecture.. Thanks!


Solution

  • First, your math is wrong: if there are four devices (A, B, C, and D), then the worst case time is 20*4 + 10 = 90ms.

    By process of elimination, though, it can't be 85, 35, or 25 (since the provided times are all multiples of 10), so the "correct" answer must be 110… but this would assume five devices, not four.