Round Robin Scheduling Program in Java

Round Robin (RR) algorithm is a CPU scheduling algorithm. It is also used in network schedulers. It is especially designed for time sharing system. It is also known as time slicing scheduling algorithm. It is closely similar to FCFS scheduling. In this section, we will discuss the round robin scheduling algorithm and its implementation in a Java program.

Round Robin Algorithm

Round Robin scheduling is the preemptive process scheduling algorithm. Each process is provided a fix time to execute in cyclic way. The fixed time is called the time quantum or time slot or time stamp or time slice. Once a process is executed for a given time period, it is preempted and other process executes for a given time period. Context switching is used to save states of preempted processes. The objective of the algorithm is to maximize the CPU utilization. The algorithm is best suited for time sharing system.

There are the following three variants of Round Robin algorithm:

  • Deficit Round Robin
  • Selfish Round Robin
  • Skip Round Robin

Before moving to the example, first we will understand the various time related to a process used in Round Robin algorithm.

  • Arrival Time: It is the time when a process enters into the ready state. It means the process is ready for execution. It is calculated as:
  • Response Time: It is the time when a process gets the CPU for the first time.
  • Turnaround Time: It is an amount of time the process exists in the system. It is calculated by using the following formulas:
  • Waiting Time: It is an amount of time taken by a process for their complete execution. In other words, the time spend by a process in the ready state waiting for CPU. It is computed by using the following formula:
  • Burst Time: Burst time is the total time taken by the process for its execution on the CPU. It is also known as execution time.
  • Completion Time: It is an amount of time taken by a process to complete. It is also known as exit time.
  • Throughput Time: It can be defined as the number of processes executed by the CPU in a given amount of time. It is used to find the efficiency of a CPU.

Advantage of Round Robin Scheduling

  • It is cyclic in nature.
  • It never leads to starvation.
  • Each task is served by CPU for a fixed time.
  • Not priorities any task.
  • It is the same as FCFS scheduling.

Round Robin Scheduling Java Program

RoundRobin.java

Output:

Round Robin Scheduling Program in Java




Latest Courses