Round Robin Scheduling with different arrival times


Scheduling algorithms of the operating system are used for scheduling the input process to the respective processor. The process scheduler has the allocation rights to decide on which process to start its execution based on any one of the scheduling algorithms. Any process in the execution state that uses CPU resources can be preempted and other process in the ready queue is chosen for execution based on priority, in terms of priority-based algorithms.

Preemptive algorithms provide access to the CPU to the process which has higher priority, and preempt if any other process which is already running with lower priority. But in the case of non-preemptive scheduling, when the initial process enters into the execution state it cannot be preempted even when the higher priority process is in the ready state.

Round Robin Algorithm

This algorithm is also preemptive where every process uses a fixed amount of time slice or quantum for its execution. For each process after the given time slice the processor sends the starting process to the queue’s end, if it has remaining burst time to execute and the rest of the processes which are in a ready state will be served in the FCFS pattern

Given below are the key functions of the RR algorithm −

  • It is known to be an effective algorithm as it does not enter into starvation mode, as all process gets their CPU time

  • The process which gets preempted during running state and has remaining execution time been moved to the end of the queue.

  • Time slice or quantum should be defined with minimum value and it may differ for various operating systems of the user.

  • RR algorithm works as clock driven model which follows a hybrid approach when using FCFS after the preemption stage.

  • Context switching technique is used for saving the process state which gets preempted during its execution

  • It is mostly used by traditional operating systems for its fast and simple working methods.

  • It is popular as a process that responds to the given events with the specified time slice and so-called real-time algorithm.

Working of Round Robin Scheduling algorithm

  • All the given processes enter into the ready queue as per arrival time.

  • When the first process goes to the execution state, other processes are in the ready queue and wait for the first process to complete its execution.

  • The first process gets executed till the quantum time (preempted), and if it has a remaining burst time then it is sent to the end of the queue.

  • If the first process completes its execution with the burst time within the specified quantum time, then the process is terminated by the scheduler.

  • This process continues until all the process completes its execution within the time period and the ready queue gets empty.

We will discuss three examples with different arrival times.

Example 1 Given are the three processes P1, P2, and P3 with different arrival times, and burst time.

Quantum time =2.

Process list

Arrival Time

Burst time

P1

0

4

P2

1

3

P3

2

7

GANTT CHART

Process list

Arrival time

Burst time

Completion time or closing time (CT)

Turn Around time(CT-AT)

Waiting time(TAT-BT)

P1

0

4

8

8-0=8

8-4=4

P2

2

3

9

9-2=7

7-3=4

P3

4

7

14

14-4=10

10-7=3

Completion time is the time period of each process when it completes its execution successfully and is taken out of the queue, which can be traced using the Gantt chart provided above.

Average WT = (4+4+3) / 3 = 3.66 units

Average TAT = (8+7+10) / 3 = 8.33 units

Example 2 Given are the processes P1, P2, and P3 with different arrival times and burst times.

Quantum time = 4.

GANTT CHART

Process list

Arrival Time

Burst time

P1

2

8

P2

0

7

P3

1

9

Process list

Arrival time

Burst time

Completion time (CT)

TAT

WT

P1

2

8

23

23-2=21

21-8=13

P2

0

7

15

15-0=15

15-7=8

P3

1

9

24

24-1=23

23-9=14

Average WT = (13+8+14) / 3 = 11.66 units

Average TAT = (21+15+23) / 3 = 19.66 units

Conclusion

Round robin algorithm is termed a preemptive algorithm because the process which is in an execution state gets preempted by the processor as it has reached the given quantum time and that is served later based on a First come first serve basis. Context switching method is used to store the current state of every process that has been preempted.

Updated on: 17-Jul-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements