S.H.Jondhale Polytechnic Dombivli (West) Maharashtra State Board of Technical Education 2023-2024
S.H.Jondhale Polytechnic Dombivli (West) Maharashtra State Board of Technical Education 2023-2024
SUBMITTED BY :-
1502. Nikita Borhade
Place:- Dombivli
Date:-
Seal of
Institute
Acknowledgment
Weekly Work
Description
o Scheduler
o Type of Scheduler
o Round Robin algorithm
Algorithm
Flowchart
Code
o Output
o Explanation
o Example
Conclusion
References
Introduction
Round Robin (RR) scheduling algorithm is a widely utilized scheduling
algorithm in multitasking. It assures fairness and starvation-free
execution of processes. Choosing the time quantum in RR is very crucial
as small time slice results in a large number of context switches and a
large time quantum increase the response time. Experimental analysis
reveals that the proposed algorithm produces a better average turnaround
time, average waiting time, and fewer context switches than existing
algorithms
The Round Robin (RR) scheduling algorithm is designed especially for
time-sharing systems. RR is the pre-emptive process scheduling
algorithm.
Round robin scheduling is the pre-emptive version of First Come First
Serve (FCFS) scheduling. Processes are dispatched in a First In First Out
(FIFO) sequence but each process is allowed to run for only a limited
amount of time.
Long term Scheduling: The long term scheduling decides which jobs or
processes are to be admitted to the ready queue (in main memory); that is, when an
attempt is made to execute a program, its admission to the setof currently
executing processes is either authorized or delayed by the long-term scheduler.
Thus, this scheduler dictates what processes are to run on a system, and the degree
of concurrency to be supported at any one time – whether many or few processes
are to be executed concurrently, and how the split between I/O-intensive and CPU-
intensive processes is to be handled. The long-term scheduler is responsible for
controlling the degree of multiprogramming. In general, most processes can be
described as either. An I/O-bound process is one that spends more of its time doing
I/O than it spends doing computations. A CPU-bound process, in contrast,
generates I/O requests infrequently, using more of its time doing computations. It
is important that a long-term scheduler selects a good process mix of I/O-bound
and CPU-bound processes.
Turnaround Time (TAT): Turnaround time may simply deal with the total time it
takes for a program to provide the required output to th:means the amount of time
taken to fulfill a request. The concept thus overlaps with lead time and can be
contrasted with cycle time. In computing, turnaround time is the total time taken
between the submission of a program/process/thread/task for execution and the
return of the complete output to the customer/user.
Arrival Time: Respect to a process. Arrival Time: Time at which the process
arrives in the ready queue. Completion Scheduling of processes/work is done to
finish the work on time.
Burst Time: Time required by a process for CPU execution. Burst Time is
actually time that is required to complete execution of particular task or process.
CPU Scheduling algorithms require Burst time as input.
Time Quantum: A special kind of an input is given with a specific time slice
which is fixed.based on which processes are terminated.
Round Robin Algorithm: One of the oldest, simplest, fairest and most widely
used algorithm is round robin (RR).In the round robin scheduling, processes are
dispatched in a FIFO manner but are given a limited amount of CPU time called a
time-slice or a quantum.
If a process does not complete before its CPU-time expires, the CPU is preempted
and given to the next process waiting in a queue. The preempted process is then
placed at the back of the ready list.
Round Robin Scheduling is preemptive (at the end of time-slice) therefore it is
effective in time-sharing environments in which the system needs to guarantee
reasonable response times for interactive users.
The only interesting issue with round robin scheme is the length of the quantum.
Setting the quantum too short causes too many context switches and lower the
CPU efficiency. On the other hand, setting the quantum too long may cause poor
response time and appoximates FCFS.
In any event, the average waiting time under round robin scheduling is often quite
long.
Round Robin Scheduling Algorithm
STEP 1:- Start
STEP 2:- We first have a queue where the processes are arranged in first
come first serve order.
STEP 4:- The first process is executed until the end of the quantum
value. After this, an interrupt is generated and the state is saved.
STEP 5:- The CPU then moves to the next process and the same method
is followed.
STEP 6:- Same steps are repeated till all the processes are over.
if(count==n-1)
count=0;
else if(at[count+1]<=time)
count++;
else
count=0;
}
printf("\nAverage Waiting Time= %f\n",wait_time*1.0/n);
printf("Avg Turnaround Time = %f",turnaround_time*1.0/n);
return 0;
}
OUTPUT:
EXPLANATION:
In the above code, we ask the user to enter the number of processes and
arrival time and burst time for each process. We then calculate the
waiting time and the turn around time using the round-robin algorithm.
The main part here is calculating the turn around time and the waiting
time. Turn around time is calculated by adding the total time taken and
subtracting the arrival time.
The waiting time is calculated by subtracting the arrival time and burst
time from the total and adding it t0 the waiting time. This is how the
round-robin scheduling takes place.
ADVANTAGES:
DISADVANTAGES:
1. If time quantum is large than the CPU burst then this algorithm become same as
FCFS and thus performance degrade.
2. If the time quantum size is very small, then the number of content switches
increases and the time quantum almost equal the time taken to switch the CPU
from one process to another. Therefore 50% of time spent in switching of
processes.
Example of round robin scheduling algorithm:
Solution:
Gantt Chart:-
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
Turnaround Time:-
P1=134
P2=37
P3=162
P4=121
Waiting Time:-
P1=134-53=81
P2=37-17=20
P3=162-68=94
P4=121-24=97
Average Waiting Time:- (81+20+94+97)/4=73
2)Example 2:Time=4
Process Burst Time
P1 24
P2 3
P3 3
Solution:
Gantt Chart:-
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
Turnaround Time:-
P1=30
P2=7
P3=10
Conclusion
Round Robin is a CPU scheduling algorithm where each process is
assigned a fixed time slot in a cyclic way. It is primarily the preemptive
version of the First come First Serve CPU Scheduling algorithm. Round
Robin CPU Algorithm generally focuses on Time Sharing technique.
References
https://www.studocu.com/in/document/marathwada-mitra-
mandals-polytechnic/computer-science/mini-project-report-
implementation-of-ro/42014027
https://www.edureka.co/blog/round-robin-scheduling-in-c/