You are on page 1of 18

Project Report On

ROUND ROBIN IN OPERATING SYSTEM


Submitted in partial fulfilment of the requirements for
the award degree of

Bachelor of Technology in CSE-AIML-A Under the


guidance of Mrs. K. Jhansi Rani Assistant Professor IT
Department

Department of Information Technology &Emerging


Technology
Malla Reddy Institute of Engineering and
Technology

Autonomous 2023-2024
MALLA REDDY INSTITUTE OF ENGINEERING &
TECHNOLOGY (Autonomus) Department of IT&ET

CERTIFICATE
This is to certified that the project report titled “ROUND ROBIN in
operating system” is being submitted by K.SAI SURAJ bearing Hall
Ticket No. 22W91A6664 in B.Tech. I Year II semester in Computer Science
and Engineering (Artificial Intelligence & Machine Learning) is a record
bono-fied work carried out by me. The results embodied in this report are
clear and genuine.

Internal Guide

ACKNOWLEDGEMENT

I would like to express our profound sense of deepest to our guide


Mrs. K. Jhansi Rani, Assistant Professor for valuable guidance and
cooperation for providing necessary facility and sources during the
entire period of the project. I profoundly thank Mr. V. Rama Krishna,
Head of the Dept., IT&ET who has been an excellent guide and a great
source of inspiration to our work. I am also thankful to the Principal
Dr . P. Srinivas for providing the necessary infrastructure and
laboratories. I wish to convey my sincere gratitude to Mrs. K. Jhansi
Rani, Lab In-charge who has enlightened us during the project work.

I express my thanks to all those who helped us one way or othre.

NAME: K.SAI SURAJ

ROLLNO: 22W91A6664
2
S. No. Topic Page No.
1. Abstract 4

2. Introduction 5

3. Applications 6

4. Important terms 7

5. Implementation of code 8-15


Advantage & disadvantage of round robin scheduling
6. 16
algorithm
7. Some points to remember 17

8. Conclusion 18

9. References 18

CONTENTS

3
ABSTRACT
The main objective of this paper is to develop a new approach for round robin scheduling
which help to improve the CPU efficiency in real time and time-sharing operating system.
There are many algorithms available for CPU scheduling. But we cannot implemented in real
time operating system because of high context switch rates, large waiting time, large
response time, large turn-around time and less throughput.
The proposed algorithm improves all the drawback of simple round robin architecture. The
author have also given comparative analysis of proposed with simple round robin scheduling
algorithm. Therefore, the author strongly feel that the proposed architecture solves all the
problem encountered in simple round robin architecture by decreasing the performance
parameters to desirable extent and thereby increasing the system throughput .

4
Introduction-Round Robin Scheduling
Round Robin(RR) scheduling algorithm is mainly designed for time-
sharing systems. This algorithm is similar to FCFS scheduling, but in
Round Robin(RR) scheduling, pre-emption is added which enables
the system to switch between processes.

 A fixed time is allotted to each process, called a quantum, for


execution.
 Once a process is executed for the given time period that
process is pre-empted and another process executes for the
given time period.
 Context switching is used to save states of pre-empted processes.
 This algorithm is simple and easy to implement and the most
important is thing is this algorithm is starvation-free as all
processes get a fair share of CPU.
 It is important to note here that the length of time quantum is
generally from 10 to 100 milliseconds in length.

Some important characteristics of the Round Robin(RR) Algorithm


are as follows:

1. Round Robin Scheduling algorithm resides under the category


of Pre-emptive Algorithms.
2. This algorithm is one of the oldest, easiest, and fairest
algorithm.
3. This Algorithm is a real-time algorithm because it responds to
the event within a specific time limit.
4. In this algorithm, the time slice should be the minimum that is
assigned to a specific task that needs to be processed. Though
it may vary for different operating systems.
5. This is a hybrid model and is clock-driven in nature.
6. This is a widely used scheduling method in the traditional
operating system.

5
APPLICATIONS
While this definition is general, there are some specific applications for a round robin.
We examine a few of these below.

(Computer operation):-In computer operations, round robin is used in a


scheduling algorithm that distributes work evenly among all available resources. This ensures
that no single resource is overworked, which can lead to errors and other issues down the
line. This is often described as round robin process scheduling. Another example of round
robin in computer operations is round robin DNS (or RRDNS), a method that allows multiple
DNS records to be created for the same IP address. This ensures that no matter how many
users are accessing the same domain name, each user has equal access to information and
services through round robin.…..Round robin scheduling algorithms distribute processes
evenly among resources. In the above example, all processes arrive simultaneously. P1 runs
and then P2, which is stopped for P3. Once all processes run, it all cycles back to P2 until it
finishes all processes.

(Sports):-

In sports teams like those found in the NFL, NBA, MLB or NHL, a round robin is a method
of scheduling where each participant plays against all other participants in the event. This is
also referred to as a round robin tournament. This is commonly used in tennis tournaments,
where round robin play determines who advances to the next round and who ends up being
eliminated.

(Gambling):-

In gambling and sports betting, a round robin is used as a betting strategy. This means that
instead of betting on one game or event, the bettors take stakes on multiple games or events.
This is also referred to as parlay betting. A round robin bet can be done in different ways with
many possible combinations, but the most common is to make round robin wagers on each
game or event in a group. For example, during sports playoffs, a round robin parlay may
occur for multiple teams playing. If one team loses, the bettor still has a chance to win with
the other teams. The advantage of this is that it increases the betting odds of winning because
there are more possible outcomes and more potential payouts.

(Stories):-

A round robin story is one that is started by one person and then continued successively by
others in turn. Whether an author can get additional turns, how many lines each person can
contribute, and how the story can be ended depend on the rules. Some websites have been
created for the telling of round robin stories by each person posting the next part of the story
as part of an online conference thread.

(Business meetings and events):-When planning business meetings and events, round robin
scheduling can be used to have all attendees take turns presenting their ideas or products.
This ensures that all attendees have an equal opportunity to share their views and be heard,
while also minimizing time wasted in the back-and-forth between speakers. Overall, round
robin arrangements allow for a fair and balanced distribution of tasks, resources, or other
opportunities among different individuals or groups within a business context

6
Important terms

1. Completion Time
It is the time at which any process completes its execution.
2. Turn Around Time
This mainly indicates the time Difference between completion
time and arrival time. The Formula to calculate the same
is: Turn Around Time = Completion Time – Arrival Time
3. Waiting Time(W.T):
It Indicates the time Difference between turn around time and
burst time.
And is calculated as Waiting Time = Turn Around Time –
Burst Time

Let us now cover an example for the same:

7
In the above diagram, arrival time is not mentioned so it is
taken as 0 for all processes.

Note: If arrival time is not given for any problem statement then it is
taken as 0 for all processes; if it is given then the problem can be
solved accordingly.

Explanation

The value of time quantum in the above example is 5.Let us now


calculate the Turn around time and waiting time for the above
example :

Turn Around Time Waiting Time


Processe Burst Turn Around Time = Waiting Time = Turn
s Time Completion Time – Around Time – Burst
Arrival Time Time

P1 21 32-0=32 32-21=11

P2 3 8-0=8 8-3=5

P3 6 21-0=21 21-6=15

P4 2 15-0=15 15-2=13
Average waiting time is calculated by adding the waiting time of all
processes and then dividing them by no.of processes.

average waiting time = waiting time of all processes/ no.of


processes

average waiting time=11+5+15+13/4 = 44/4= 11ms

C++ Implementation For RR Scheduling

8
// Program implementation in C++ for Round Robin
scheduling

#include<iostream>

using namespace std;

//The Function to find the waiting time for all


processes

void fWaitingTime(int processes[], int n,

int bt[], int wt[], int quantum)

// Let us Make a copy of burst times bt[] to


store remaining burst times

int rem_bt[n];

for (int i = 0 ; i < n ; i++)

rem_bt[i] = bt[i];

int t = 0; // for Current time

// Let us keep traverse the processes in the


round robin manner until all of them are not done.

9
while (1)

bool done = true;

//let us Traverse all processes one by


one repeatedly

for (int i = 0 ; i < n; i++)

// If burst time of a process is


greater than 0 then there is a need to process
further

if (rem_bt[i] > 0)

done = false; // indicates


there is a pending process

if (rem_bt[i] > quantum)

// By Increasing the
value of t it shows how much time a process has
been processed

t += quantum;

10
// Decreasing the
burst_time of current process by the quantum

rem_bt[i] -= quantum;

// If burst time is smaller


than or equal to the quantum then it is Last cycle
for this process

else

// Increase the value of


t to show how much time a process has been
processed

t = t + rem_bt[i];

// Waiting time is
current time minus time used by this process.

wt[i] = t - bt[i];

// As the process gets


fully executed thus remaining burst time becomes
0.

rem_bt[i] = 0;

11
}

// If all the processes are done

if (done == true)

break;

// Function used to calculate the turn around time

void fTurnAroundTime(int processes[], int n,

int bt[], int wt[],


int tat[])

// calculating turnaround time by adding


bt[i] + wt[i]

for (int i = 0; i < n ; i++)

tat[i] = bt[i] + wt[i];

12
// Function to calculate the average time

void findavgTime(int processes[], int n, int bt[],

int
quantum)

int wt[n], tat[n], total_wt = 0, total_tat =


0;

// Function to find waiting time of all


processes

fWaitingTime(processes, n, bt, wt, quantum);

// Function to find turn around time for all


processes

fTurnAroundTime(processes, n, bt, wt, tat);

// Display processes along with all details

cout << "Processes "<< " Burst time "

<< " Waiting time " << " Turn around


time\n";

// Calculate the total waiting time and total


turn

13
// 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 = "

<< (float)total_wt / (float)n;

cout << "\nAverage turn around time = "

<< (float)total_tat / (float)n;

//Given below is the Driver Code

int main()

// process id's
14
int processes[] = { 1, 2, 3,4};

int x = sizeof processes / sizeof


processes[0];

// Burst time of all processes

int burst_time[] = {21, 13, 6,12};

// Time quantum

int quantum = 2;

findavgTime(processes, x, burst_time,
quantum);

return 0;

Copy

Output

The output of the above code is as follows:

15
Advantages of Round Robin Scheduling Algorithm

Some advantages of the Round Robin scheduling algorithm are as


follows:

 While performing this scheduling algorithm, a particular time


quantum is allocated to different jobs.
 In terms of average response time, this algorithm gives the
best performance.
 With the help of this algorithm, all the jobs get a fair allocation
of CPU.
 In this algorithm, there are no issues of starvation or convoy
effect.
 This algorithm deals with all processes without any priority.
 This algorithm is cyclic in nature.
 In this, the newly created process is added to the end of the
ready queue.
 Also, in this, a round-robin scheduler generally employs time-
sharing which means providing each job a time slot or
quantum.
 In this scheduling algorithm, each process gets a chance to
reschedule after a particular quantum time.

Disadvantages of Round Robin Scheduling Algorithm

Some disadvantages of the Round Robin scheduling algorithm are


as follows:

 This algorithm spends more time on context switches.


 For small quantum, it is time-consuming scheduling.
 This algorithm offers a larger waiting time and response time.
 In this, there is low throughput.
 If time quantum is less for scheduling then its Gantt chart
seems to be too big.

16
Some Points to Remember

1.Decreasing value of Time quantum

With the decreasing value of time quantum

 The number of context switches increases.


 The Response Time decreases
 Chances of starvation decrease in this case.

For the smaller value of time quantum, it becomes better in terms


of response time.

2.Increasing value of Time quantum

With the increasing value of time quantum

 The number of context switch decreases


 The Response Time increases
 Chances of starvation increases in this case.

For the higher value of time quantum, it becomes better in terms of


the number of the context switches.

3. If the value of time quantum is increasing then Round Robin


Scheduling tends to become FCFS Scheduling.

4.In this case, when the value of time quantum tends to infinity then
the Round Robin Scheduling becomes FCFS Scheduling.

5. Thus the performance of Round Robin scheduling mainly depends


on the value of the time quantum.

6.And the value of the time quantum should be such that it is


neither too big nor too small.

17
CONCLUSION
A comparative study of simple RR algorithm and proposed one is made. It is
concluded that the proposed algorithm is superior as it has less waiting response
time, usually less pre-emption and context switching thereby reducing the
overhead and saving of memory space. Future work can be based on this
algorithm modified and implemented for hard real time system where hard
deadline systems require partial outputs to prevent catastrophic events. Round
robin is one of the oldest, fairest, and most extensively utilized scheduling
algorithms in conventional operating systems. The most significant benefit of the
round-robin scheduling algorithm is that all the jobs get an unbiased allocation
of CPU, and it deals with all processes without any priority. This technique takes
more time to transition between contexts.

REFERENCE
Wikipedia about round robin…….
https://www.studocu.com/in/u/4201402
7?sid=01703323447

Studytonight.com (question)

About round robin scheduling


algorithm????????????????

18

You might also like