IN-FEED-AD

Round Robin Algorithm- CPU Scheduling - Operating System

Round Robin Algorithm- CPU Scheduling - Operating System

  • Round Robin is the preemptive process scheduling algorithm.
  • CPU is assigned to the process on the basis of FCFS for a fixed amount of time.
  • Each process is provided a fix time to execute, it is called a quantum.
  • Each process present in the ready queue is assigned the CPU for that time quantum, if the execution of the process is completed during that time then the process will terminate else the process will go back to the ready queue and waits for the next turn to complete the execution.
  • Once a process is executed for a given time period, it is preempted and other process executes for a given time period.

Example:-

there are Five processes named as P1, P2, P3, P4,and P5. Their arrival time and burst time are given below in the table. The time quantum of the system is 4 units. 
According to algorithm we have to maintain ready queue and gantt chart. 

CPU Scheduling Example-Round Robin Algorithm

Step-1 Initially at t=0,Process will be schedule for time quantum 4 unit. Hence in the ready queue there will be only one process i.e. P1
    Ready Queue:- 
CPU Scheduling-Round Robin Algorithm
    Gantt Chart:- 
Cpu Scheduling Algorithm- Round Robin Algorithm
Step-2:- After The execution, four more processes P2,P3, P4,and P5 arrives in the ready Queue, since P1 is not completed yet , it needs another 1 unit time hence it will also added back to ready queue.
Ready Queue:-
CPU Scheduling Algorithm- Round Robin Algorithm
Gantt Chart:-
CPU Scheduling Example-Round Robin Algorithm
Step-3:- Since Process P2 is not completed yet so P2 will be added back to Ready Queue,

Ready Queue:- 
CPU Scheduling Example-Round Robin Algorithm
Gantt Chart:-
CPU Scheduling Example-Round Robin Algorithm
Step-4:- Now Process P3 is completed so it will not be added back to ready queue.
Ready Queue:-
CPU Scheduling Example-Round Robin Algorithm
Gantt Chart:-
CPU Scheduling Example-Round Robin Algorithm
Step-5:- Process P4 is completed, so it will not be added back to ready queue, Now Process P5 will be executed.
Ready queue:-
CPU Scheduling Example-Round Robin Algorithm
Gantt Chart:-
CPU Scheduling Example-Round Robin Algorithm

Step-6:-
Process P5 is completed, so it will again added to Ready Queue
Ready Queue:- 
CPU Scheduling Example-Round Robin Algorithm
Gantt Chart:-
CPU Scheduling Example-Round Robin Algorithm
Step-7:- Process P1 is completed, so it will not be added back to Ready Queue
Ready Queue:-
CPU Scheduling Example-Round Robin Algorithm
Gantt Chart:- 
CPU Scheduling Example-Round Robin Algorithm
Step-8 Process P2 is completed , so it will not be added back to Ready queue
Ready Queue:-
CPU Scheduling Example-Round Robin Algorithm


Gantt Chart:-
CPU Scheduling Example-Round Robin Algorithm 
Now we will Calculate Turn around time, completion time and Waiting time 


Related Other Post

Turn around Time:-

It is the time interval from the time of submission of a process to the time of the completion of the process.
                    TAT=Completion Time – Arrival time

Waiting Time:- 

The time spent by a process waiting in the ready queue for getting the CPU.
                Waiting time=Turn Around Time-Burst Time


CPU Scheduling Example-Round Robin Algorithm

CPU Scheduling Example-Round Robin Algorithm

Average Waiting time = (12+12+6+8+11)/5=9.8 Unit

Characteristics Of Round Robin Algorithm:-

  • The name of this algorithm comes from the round-robin principle, where each person gets an equal share of something in turns.
  • It is the oldest, simplest scheduling algorithm, which is mostly used for multitasking.
CPU Scheduling Example-Round Robin Algorithm

Disadvantages

  • There is Low throughput.
  • The higher the time quantum, the higher the response time in the system.
  • The lower the time quantum, the higher the context switching overhead in the system.

Ask question #Pywix

Please Like, Comment, Share and Subscribe THANK YOU!


Post a Comment

0 Comments