Operating System[1]
Operating System[1]
• The period of time for which a process or job is allowed to run in a pre-emptive method is called
time quantum.
• Each process or job 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 end else the process will go back to the waiting
table and wait for its next turn to complete the execution.
PURPOSES : The primary purpose of Round Robin scheduling is to provide fairness and
responsiveness in a multiprogramming environment. It ensures that each process gets a fair
share of CPU time, preventing any single process from monopolizing the system.
Key Objective Of Round Robin:
Fairness: Every process receives an equal time slice (time quantum) of CPU
time, ensuring that no process is starved or denied access to the CPU
indefinitely.
• ROUND ROBIN CPU Sheduling algorithm generally focus on TIME Sharing technique.
The period of time for which a process or job is allowed to run in a pre-emptive method is called
time quantum.
• Each process or job 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 end else the process will go
back to the waiting table and wait for its next turn to complete the execution.
1 Arrival Time The moment when a process enters the ready queue and is eligible for execution
by the CPU.
2 Burst Time The amount of CPU time a process needs to finish its execution
3 Waiting Time Long burst time processes that execute before other processes can cause a long
wait time in the queue
4 Turn Around Time It’s indicates the time Difference between completion time and arrival time. The
Formula to calculate the same is: Turn Around Time = Completion Time – Arrival
Time.
5 Completion Time It’s the exact time when a process finishes the execution.
ADVANTAGE OF ROUND ROBIN
Advantage :
•No issues of starvation effect.
•Every job gets a fair allocation of CPU.
•No priority scheduling is involved.
•Doesn’t depend on burst time and is easily implementable.
•When a process executes for a specific time, it is preempted, and another process takes
its place executing for that same time period.
•Best performance in terms of average response time.
DISADVATAGE OF ROUND ROBIN
Disadvantage :
•SPEN DS MOR E TIME ON CONTEXT SWITCHIN G.
•PER FOR MAN CE DEPEN DS ON TIM E QUAN TUM.
•PROCESSES DON ’T HAVE PR IOR ITIES.
•N O SPECIAL PRIORITY TO MORE IMPORTAN T TASKS.
•HIGHER CON TEXT SWITCHIN G OVER HEAD DUE TO LOWER
TIME QUAN TUM.
•DIF F ICULT TO F IN D A COR R ECT TIM E QUAN TUM.
Algorithm for Round Robin
•Initialize ready queue: Create a queue to hold processes waiting for CPU time.
•Select first process: Choose the first process from the ready queue.
•Allocate time quantum: Assign a fixed time quantum to the selected process.
•Execute process: Let the process execute for the allocated time quantum.
•Check completion:
•If the process completes within the quantum, remove it from the ready queue and calculate its turnaround
time, waiting time, and response time.
•If the process doesn't complete within the quantum, preempt it and place it at the end of the ready queue.
•Select next process: Choose the next process from the ready queue and repeat steps 3-5.
For P1,P2,P3 process the time quantum is 2 units. Every process use the cpu for the 2 units of
time .
P1 P2 P3 P1 P2 P1 P1
GANTT CHART
In conclusion, Round Robin CPU scheduling is a fair and preemptive algorithm that allocates a fixed
time quantum to each process, ensuring equal CPU access. It is simple to implement but can lead to
higher context-switching overhead. While it promotes fairness and prevents starvation, it may result
in longer waiting times and reduced throughput, depending on the time quantum. Effective
program implementation allows for the calculation of key metrics like completion time, turnaround
time, and waiting time, aiding in performance evaluation and optimization.
THANK YOU