0% found this document useful (0 votes)
21 views29 pages

OSY Project

The document presents a project on the Round Robin scheduling algorithm, submitted for a Diploma in Computer Engineering. It includes an abstract, introduction, and detailed explanations of the Round Robin and FCFS algorithms, along with their implementations in C++. The project concludes with an analysis of performance metrics such as average waiting time and turnaround time.

Uploaded by

Anurag Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views29 pages

OSY Project

The document presents a project on the Round Robin scheduling algorithm, submitted for a Diploma in Computer Engineering. It includes an abstract, introduction, and detailed explanations of the Round Robin and FCFS algorithms, along with their implementations in C++. The project concludes with an analysis of performance metrics such as average waiting time and turnaround time.

Uploaded by

Anurag Pawar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

“Round Robin Algorithm”

A Project
Submitted in partial fulfilment of the requirement for the award of
Diploma in
Computer Engineering Discipline
Submitted To

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION, MUMBAI.


(DTE Code: 5009)

Submitted by:-

Ms. Yogita Sharad Deore Enrollment No:- 2214320040


Ms. Sayali Nandu Shinde Enrollment No:- 2214320003

Under the Guidance of


Prof Mr. M.M.Goswami

DEPARTMENT OF COMPUTER ENGINEERING


GOVERNMENT POLYTECHNIC
NANDURBAR. DIST: NANDURBAR (MSBTE CODE:-1432)
GOVERNMENT POLYTECHNIC,
NANDURBAR, DIST– NANDURBAR (MSBTE CODE: 1432)

CERTIFICATE
This is to certify that….

Ms. Yogita Sharad Deore Enrollment No:-2214320040


Ms. Sayali Nandu Shinde Enrollment No:-2214320003

Has satisfactorily completed project entitled

“Operating System”
As prescribed by Maharashtra State Board of Technical Education,
Mumbai as a part of syllabus for the partial fulfilment in Diploma in
Computer Engineering for Academic year 2024-25.

GUIDE H.O.D
Prof.M.M.Goswami Prof. S.B. Thakre

EXAMINER PRINCIPAL
--------------------- Dr. S.B.Wesley
GOVERNMENT POLYTECHNIC,
NANDURBAR, DIST– NANDURBAR (MSBTE CODE: 1432)

CERTIFICATE OF APPROVAL

The Project entitled “Round Robin Algorithm” being submitted by


“Yogita Sharad Deore, Sayali Nandu Shinde” has been examined by us and
is hereby approved for the partial award of Diploma in Computer
Engineering for which it has been submitted. It is understood that by this
approval the undersigned do not necessarily endorse or approve any
statement made, opinion expressed or conclusion drawn there in, but
approve the project only for the purpose for which it has been submitted.

(External Examiner) (Internal Examiner)


Date: Date:
INDEX

Sr. No Title Page No

1 Abstract 05

2 Introduction 06

CONCEPT
1.1) FCFS
3 07-13
1.2) Round Robin Algorithm
1.3) Example with solution
4 Use Case Diagram 14

Data Flow Diagram


2.1) FCFS
5
2.2) ROUND ROBIN

Class Diagram
6

7 Output

8 Conclusion

9 References
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.
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
primitive 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.
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:
Process Burst time

P1 25

P2 4

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

The waiting time for P1 is 0 milliseconds, for P2 it is 25 milliseconds


and 29 milliseconds for P3. Thus, average waiting time is
(0+25+29)/3=18 milliseconds.

Advantage:

 It is easy to understand and implement.


 Simple
 Easy
 First come, First serve
Disadvantage:

 It is a Non-Pre-emptive scheduling algorithm: Once a


process has been allocated the CPU, it will not release
the CPU until it finishes executing. Thus, it is not
suitable for modern systems which work on the
principle of time sharing.
 The Average Waiting Time is high.
 It results in convey effect i.e., many processes which
require CPU for short duration have to wait for a bigger
process to finish thus resulting in low resource
utilization.

Implementation:

1) Input the process along with their burst time (bt).


2) Find waiting time (wt) for all processes.
3) As first process that comes need not to wait so waiting
time for process 1 will be i.e. wt[0]=0.
4) Find waiting time for all other processes i.e. for process
i ->
wt[i] = bt[i-1] + wt[i-1].
5) Find Turnaround time = waiting time + burst time for all
processes.
6) Find average waiting time =
total_turn_around_time/no_of_processes.
7) Similarly, find average turnaround time =
total_turn_around_time/no_of_processes.
Code
//C++ program for implementation of FCFS

//scheduling

#include<iostream>

Using namespace std;

//Function to find the waiting time for all

//processes

Void findWaitingTime (int processes[],int n, int b[], int wt[])

//waiting time for first process is 0

wt[0]=0;

//calculating waiting time

For(int i = 1; i < n; i++)

wt[i] = bt[i-1] + wt[i-1];

//function to calculate turnaround time

Void findTurnAroundTime (int processes[], int n, int bt[], int wt[],


int that[])

//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 findvg Time(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; j<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;
}
//Driver code
Int main()
{
//process id’s
int processes[]={1,2,3};
int n = size pf processes/size of processes[0];
//Burst time of all processes
int burst_time[]={10,5,8};
findvgTime(processes, n, burst_time);
return 0;
}
}
Manual Output:

Processes Burst time Waiting Turn


Time around
time

1 10 0 10

2 5 10 15

3 8 15 23

Average waiting time=8.33333


Average turn around time=16
System Output:
Use Case Diagram of FCFS

Fig. Use case Diagram for FCFS Algorithm


Data Flow Diagram for FCFS

Fig. Data Flow Diagram for FCFS Algorithm


Class Diagram for FCFS
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 ireemptive as processes are assigned CPU only for a
fixed slice of time at most.
 The disadvantage of it is more overhead of context
switching

To schedule processes fairly, a round-robin scheduler generally employs


time-sharing, giving each job a time slot or (its allowance of CPU time),
and interrupting the job if it is not completed by then. The job is
resumed next time a time slot is assigned to that process. If the process
terminates or changes its state to waiting during its attributed time
quantum, the scheduler selects the first process in the ready queue to
execute. In the absence of time-sharing, or if the quanta were large
relative to the sizes of the jobs, a process that produced large jobs would
be favoured over other processes.

 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.

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
Steps to find waiting times of all processes:

1) Create an array rem_bt[] to keep


track of remaining burst time of
processes. This array is initially a
copy of bt[] (burst times array)
2) Create another array wt[] to store
waiting times of processes. Initialize
this array as
3) Initialize time: t = 0
4) Keep traversing the all processes
while all processes are not done. Do
following for it’s process if it is not
done yet.
a- If rem_bt[i] >
quantum (i) t = t
+ quantum (ii)
bt_rem[i] -=
quantum; c- Else
// Last cycle for this
process
I. t = t + bt_rem[i];
II. wt[i] = t - bt[i]
III. bt_rem[i] = 0; // This process is
over
Code with the example no2: -

// C++ program for implementation of RR scheduling


#include<iostream>
Using namespace std;

//Function to find the waiting time for all


//processes
void findWaitingTime(int processes[],int n, int bt[], int wt[], int
quantum)
{
//Make a copy of burst times bt[] to store remaining
//burst times.
int rem_bt
//Current time
//Keep traversing processes in round robin manner
//until all of them are not done.
while(1)
{
Bool done=true;
//Traverse all processes one by one repeatedly
For(int i=0;i<n;i++)
{
//If burst time of process is greater than 0
//then only need to process further
If(rem_bt[i]>0)
{
Done=false; //There is a pending process
If(rem_bt[i]>quantum)
{
//Increase the value of t i.e., shows
//how much time a process has been processed
t+=quantum;

//Decrease the burst_time of current process


//by quantum

rem_bt[i]=quantum;
}
//If burst time is smaller than or equal to
//quantum.Last cycle for this process
Else
{
//Increase the value of t i.e., shows
//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


//make its remaining burst time=0
Rem_bt[i]=0;
}
}
}
//If all processes are done
if(done==true)
break;
}
}

//Function to calculate turn around time


Void findTurnAroundTime(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];
}

//function to calculate 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 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=”
<<(float)total_wt/(float)n;
cout<< “Average turn around time= “
<<(float)total_tat/(float)n;
}
//Drive code
int main()
{
//process id’s
int processes[]={1,2,3];
int n=size of processes/size of processes[0];
//Burst time of all processes
int burst_time[]={10,5,8};
//Time quantum
int quantum=2;
findavgTime(processes, n, burst_time, quantum);
return 0;
}
Manual Output

Processes Burst time Waiting Turn


Time around
time

1 10 13 23

2 5 10 15

3 8 13 21

Average waiting time = 12


Average turn around time = 19.6667

System Output:
Use case Diagram of Round Robin
Data flow Diagram of Round Robin
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.
Weekly Work / Progress Report

Details of Engagement Hours of the Student


Regarding Completion of the Project
Week Duration Sign of
No. Date in hours Work or activity Performed the Guide

1 Two hours Discussion and Finalization of the


Project Title
2 Two hours Preparation and Submission of
Abstracts
3 Two hours Literature Review
4 Two hours Collection of Data

5 Two hours Collection of Data

6 Two hours Discussion and outline of content

7 Two hours Rough Writing of the Project


Contents
8 Two hours Editing and Proof Reading of the
Contents
9 Two hours Final Completion of the Project

10 Two hours Seminar Presentation, viva-vice,


Assessment and Submission of
Report
Comment/Suggestion about team
Work/Leadership/Interview personal communication
All the team members were co-operative and helped each other. The
team members gave full support.
Rather, there were no any misunderstanding among.

Marks out of Marks out of


Roll Student Name 6 for 4 for
No. performance performance Total Remark
in activities in oral/
presentation
3123 Yogita Sharad
Deore
3102 Sayali Nandu
Shinde

You might also like