(Prof. S.S.Sarkate) : " Round Robin Algorithm "
(Prof. S.S.Sarkate) : " Round Robin Algorithm "
A STYDY ON
[ PROF. S.S.SARKATE ]
Three Years Diploma Program in Engineering & Technology of Maharashtra State Board of
Technical Education, Mumbai (Autonomous)
ISO 9001:2008 (ISO/IEC-27001:2013)
at
[ SHRI SAI POLYTECHNIC, CHANDRAPUR ]
1
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, MUMBAI
Certificate
7) Maheshwari Zade
Fifth Semester of Computer Engineering Diploma in Engineering & Technology at [ SHRI SAI
POLYTECHNIC, CHANDRAPUR ] , has completed the Micro Project satisfactorily in Subject
OPERATING SYSTEM in the academic year2020-2021 as per the MSBTE prescribed curriculum of I
Scheme.
Place: Chandrapur
Head of
Institute 2
INDEX
Abstract 4
1. Introduction 5-8
2. Code 9-11
3. Output 12
6. Class Diagram 15
7. Algorithm 16-17
3
Abstract
Round Robin (RR) scheduling algorithm is the widely used scheduling algorithm in
multitasking. It ensures fairness and starvation free execution of processes. Choosing the time
quantum in RR algorithm is very crucial as small time slice results in large number of context
switches and large time quantum increases the response time. To overcome these problems of
RR scheduling, instead of static time slice dynamic time slice can be used to get optimal
performance. The objective of this paper is to modify RR algorithm by adjusting time slices of
different rounds depending on the remaining CPU bursts of currently running processes and
considering their waiting times until that round in respect of the other processes waiting times.
Experimental analysis reveals that the proposed algorithm produces better average turnaround
time, average waiting time and fewer number of context switches than existing algorithms.
4
Introduction
Round Robin is a CPU scheduling algorithm where each process is assigned a fixed time slot in a
cyclic way. It is simple, easy to implement, and starvation-free as all processes get fair share of
CPU. One of the most commonly used technique in CPU scheduling as a core. It is preemptive
as processes are assigned CPU only for a fixed slice of time at most. The disadvantage of it is
more overhead of context switching.
FIFO simply queues processes in the order that they arrive in the ready queue. This is commonly
used for a task queue, for example as illustrated in this section.
5
First Come, First Served (FCFS)
First Come First Serve is the simplest and easiest scheduling algorithm. In this algorithm, the
CPU is allocated to the processes in the order they request it. The implementation of FCFS is
easily done with a queue (a FIFO structure). When the first process enters the system it starts its
execution immediately and runs till it completes its execution. As other processes enter the
system, they are put at the end of the queue and wait to get the CPU. When a process finishes
executing, it releases the CPU, is removed from the queue and the CPU is allocated to next
process at the head of the queue.
First come, first served (FCFS) is an operating system process scheduling algorithm and a
network routing management mechanism that automatically executes queued requests
and processes by the order of their arrival.
With first come, first served, what comes first is handled first; the next request in line will
be executed once the one before it is complete.
FCFS is also known as first-in, first-out (FIFO) and first come, first choice (FCFC).
Example:
P1 25
P2 4
6
P3 3
The processes arrive in the order P1, P2, P3 and are served as per the FCFS algorithm. The
Gantt chart is as shown:
P1 P2 P3
0 25 29 32
Advantage:
o It is easy to understand and implement.
o Simple
o Easy
Disadvantage:
7
Implementation:
8
Code
9
// calculating turnaround time by adding
// bt[i] + wt[i]
for (int i = 0; i < n ; i++)
tat[i] = bt[i] + wt[i];
}
//Function to calculate average time
void findavgTime( int processes[], int n, int bt[])
{
int wt[n], tat[n], total_wt = 0, total_tat = 0;
//Function to find waiting time of all processes
findWaitingTime(processes, n, bt, wt);
//Function to find turn around time for all processes
findTurnAroundTime(processes, n, bt, wt, tat);
//Display processes along with all details
cout << "Processes "<< " Burst time "
<< " Waiting time " << " Turn around time\n";
// Calculate total waiting time and total turn
// around time
for (int i=0; i<n; i++)
{
total_wt = total_wt + wt[i];
total_tat = total_tat + tat[i];
cout << " " << i+1 << "\t\t" << bt[i] <<"\t "
<< wt[i] <<"\t\t " << tat[i] <<endl;
}
cout << "Average waiting time = "
10
<< (float)total_wt / (float)n;
cout << "\nAverage turn around time = "
<< (float)total_tat / (float)n;
}
// Driver code
int main()
{
//process id's
int processes[] = { 1, 2, 3};
int n = sizeof processes / sizeof processes[0];
//Burst time of all processes
int burst_time[] = {10, 5, 8};
findavgTime(processes, n, burst_time);
return 0; }
}
11
OUTPUT
Manual Output:
2 5 10 15
3 8 15 23
System Output:
12
Use case Diagram of FCFS
13
Data Flow Diagram for FCFS
14
Class Diagram for FCFS
15
Round Robin scheduling algorithm
Round Robin is a CPU scheduling algorithm where each process is assigned a fixed time slot in a
cyclic way.
It is simple, easy to implement, and starvation-free as all processes get fair share of CPU.
One of the most commonly used technique in CPU scheduling as a core.
It is preemptive as processes are assigned CPU only for a fixed slice of time at most.
The disadvantage of it is more overhead of context switching
Round-robin algorithm is a pre-emptive algorithm as the scheduler forces the process out
of the CPU once the time quota expires.
For example, if the time slot is 100 milliseconds, and job1 takes a total time of 250 ms to
complete, the round-robin scheduler will suspend the job after 100 ms and give other jobs
their time on the CPU. Once the other jobs have had their equal share (100 ms
each), job1 will get another allocation of CPU time and the cycle will repeat. This
process continues until the job finishes and needs no more time on the CPU.
16
1)Completion Time: Time at which process completes its execution.
2)Turn Around Time: Time Difference between completion time and arrival time.
3)Turn Around Time = Completion Time – Arrival Time
4)Waiting Time(W.T): Time Difference between turn around time and burst time.
5)Waiting Time = Turn Around Time – Burst Time
17
Conclusion
Thus we have performed various scheduling algorithms such as FCFS(First Come First Serve)
and Round Robin Algorithm. We have developed a C plus program to execute these algorithms.
We have calculated waiting time, turnaround time, burst time. We have created Use case and
Data Flow Diagram for both algorithms.
References
www.aapliuniversity.com
www.codewithc.com
Techknowledge publication book: Operating System
18