RR is a preemptive scheduler, which is designed especially for time-sharing systems. In other words, it does not wait for a process to finish or give up control. In RR, each process is given a time slot to run. If the process does not finish, it will “get back in line” and receive another time slot until it has completed. RR can be implemented using a FIFO queue where new jobs are inserted at the tail end.

 

fifo_queue fQ                     // FIFO queue

add_task (proc) {               // method to add a task
   fQ.add_tail(proc)
}

reschedule(why) {              // method to remove the next process and run it
    if (why == timer) 
       add_task(current);
       set_timer(time quanta);
       return fQ.remove_head;
}

 

RR assigns a time quanta (i.e. time slot) to each process waiting to be run. For the jobs A, B, C and D in the previous example, RR’s Gantt chart would be:

If time quanta = 3

If time quanta = 6

 

RR

Utilization

26/(26+9CS)

Turn around time

(23+16+26+21)/4 = 21.5 ignoring CS

Waiting

(15+12+17+16)/4 = 15 ignoring CS

Throughput

4/(26 + 9CS)

Response

(0+3+6+9)/4 = 4.5 ignoring CS

 The performance of RR depends on the size of the time quantum, and if the time quantum is large, RR will behave just like the FCFS policy. In general, the time quantum to be large with respect to the context-switch time(cs should be around 10% of time quantum)