0% found this document useful (0 votes)
58 views19 pages

S.H.Jondhale Polytechnic Dombivli (West) Maharashtra State Board of Technical Education 2023-2024

This document is Nikita Borhade's micro project report on implementing a round robin scheduling algorithm in C. It was submitted to S.H. Jondhale Polytechnic in Dombivli, Maharashtra for their diploma in computer engineering. The report includes an introduction to round robin scheduling, a weekly work log of the project, descriptions of scheduling and the round robin algorithm, code examples and output, and applications of the micro project.

Uploaded by

anushka patil
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)
58 views19 pages

S.H.Jondhale Polytechnic Dombivli (West) Maharashtra State Board of Technical Education 2023-2024

This document is Nikita Borhade's micro project report on implementing a round robin scheduling algorithm in C. It was submitted to S.H. Jondhale Polytechnic in Dombivli, Maharashtra for their diploma in computer engineering. The report includes an introduction to round robin scheduling, a weekly work log of the project, descriptions of scheduling and the round robin algorithm, code examples and output, and applications of the micro project.

Uploaded by

anushka patil
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/ 19

S.H.

JONDHALE POLYTECHNIC DOMBIVLI (WEST)


MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION
2023-2024

MICRO PROJECT REPORT ON :-


“ PROGRAM IN ‘C’ FOR ROUND ROBIN SCHEDULING
ALGORITHM ”

SUBMITTED BY :-
1502. Nikita Borhade

UNDER THE GUIDANCE OF :-


MR.

IN THE PRACTICAL FULFILMENT FOR THE AWARD OF DIPLOMA IN


COMPUTER ENGINEERING
MAHARASTRA STATE BOARD OF TECHNICAL
EDUCATION
Certificate
This Is Certify That (1502) Ms. Nikita Borhade Of Fifth Semester Of

Diploma In Computer Engineerring Of Institutes S.H. Jondhale

Polytechnic Dombivli (West) (Code:0044) has completed the

Microproject satisfactorily in course Operating System (22516) For

The Academic Year 2023-2024 as prescribed in the curriculum.

Place:- Dombivli
Date:-

Course Teacher Head of the Department Principal

Seal of
Institute
Acknowledgment

We would like to express my special thanks to our sir ‘Mr. For


guidance and support. On the successful completion of our
project report “ Program In ‘C’ For Round Robin Scheduling
Algorithm ”, we would like to express our sincere gratitude to
everyone who help us in the completion of the project. We are
sincerely thankful to our project guide for him interest, guidance
and suggestions throughout the course of the project. We feel
Honoured and Privileged to work under him. He shared him vast
pool of knowledge with us that help us steer through all the
difficulties with ease. This project would not have been possible
without sir guidance.
ABSTRACT
An Operating System is basically a system program that controls
the execution of application programs and acts as an interface
between applications and the computer hardware. It manages the
computer system resources to be used in an efficient manner.
This course enables one to learn the internal functioning of
operating systems and will help in identifying appropriate
Operating Systems for given applications/tasks.
In this micro project, we may like to put forth information about
Round Robin Scheduling Algorithm. 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
necessary 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
makes a better average turnaround time, average waiting time,
and fewer context switches than existing algorithms.
Index
Introduction

Weekly Work

Description
o Scheduler
o Type of Scheduler
o Round Robin algorithm

Algorithm

Flowchart
Code
o Output
o Explanation
o Example

Applications Of Micro Project

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

Round Robin Scheduling is a scheduling algorithm used by the system


to schedule CPU utilization. This is a preemptive algorithm. There exist
a fixed time slice associated with each request called the quantum. The
job scheduler saves the progress of the job that is being executed
currently and moves to the next job present in the queue when a
particular process is executed for a given time quantum.
Weekly Work

Working Date Details of activity


24|07|23 – 30|07|23 Searching the topic for micro-project.

31|07|23 – 06|08|23 Discussion with subject Guide.


07|08|23 – 13|08|23 Understand the topic.
14|08|23 – 20|08|23 Gathered information about topic.
21|08|23 – 27|08|23 Collect information from the OSY
(22516) reference book.
28|08|23 – 03|09|23 Didn’t do any work.
04|09|23 – 10|09|23 Debugged the errors.
11|09|23 – 17|09|23 Arrange all information in MS word.
18|09|23 – 24|09|23 Prepare a report on it using MS word.

25|09|23 – 01|10|23 Didn’t do any work.


02|10|23 – 08|10|23 Solved some examples.
09|10|23 – 15|10|23 Created document.
16|10|23 – 22|10|23 Verified by subject Guid.
23|10|23 – 24|10|23 Took printout respectively.
30|10|23 – 05|11|23 Submitted the project.
Description
Operating System Schedulers: The scheduler is an operating system module
that selects the next jobs to be admitted into the system and the next process to run.
Operating systems may feature up to three distinct scheduler types: a long-term
scheduler (also known as an admission scheduler or high-level scheduler), a mid-
term or medium-term scheduler, and a short-term scheduler. The names suggest the
relative frequency with which their functions are performed.

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.

Medium term Scheduling: The medium term scheduling temporarily removes


processes from main memory and places them in secondary memory (such as a
hard disk drive) or vice versa, which is commonly referred to as "swapping out" or
"swapping in" (also incorrectly as "paging out" or "paging in"). The medium-term
scheduler may decide to swap out a process which has not been active for some
time, or a process which has a low priority, or a process which is page faulting
frequently, or a process which is taking up a large amount of memory in order to
free up main memory for other processes, swapping the process back in later when
more memory is available, or when the process has been unblocked and is no
longer waiting for a resource.
Short term Scheduling: The short term scheduling(also known as the CPU
scheduler) decides which of the ready, in-memory processes is to be executed
(allocated a CPU) after a clock interrupt, an I/O interrupt, an operating system call
or another form of signal. Thus the short-term scheduler makes scheduling
decisions much more frequently than the long-term or mid-term schedulers – a
scheduling decision will at a minimum have to be made after every time slice, and
these are very short. This scheduler can be preemptive, implying that it is capable
of forcibly removing processes from a CPU when it decides to allocate that CPU to
another process, or non-preemptive (also known as "voluntary" or "co-operative"),
in which case the scheduler is unable to "force" processes off the CPU.

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.

Waiting Time: Throughput: number of processes completed per unit time.


Turnaround Time: mean time from submission to completion of process. Waiting
Time: Amount of time spent ready to run but not running. Response Time: Time
between submission of requests and first response to the request.

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 3:- A quantum value is allocated to execute each process.

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.

STEP 7:- End


Flowchart
Code
C Program Code
Round Robin Scheduler Algorithm-
#include<stdio.h>
int main()
{
int count,j,n,time,remain,flag=0,time_quantum;
int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10];
printf("Enter Total Process:\t ");
scanf("%d",&n);
remain=n;
for(count=0;count<n;count++)
{
printf("Enter Arrival Time and Burst Time for Process Process Number %d
:",count+1);
scanf("%d",&at[count]);
scanf("%d",&bt[count]);
rt[count]=bt[count];
}
printf("Enter Time Quantum:\t");
scanf("%d",&time_quantum);
printf("\n\nProcess\t|Turnaround Time|Waiting Time\n\n");
for(time=0,count=0;remain!=0;)
{
if(rt[count]<=time_quantum && rt[count]>0)
{
time+=rt[count];
rt[count]=0;
flag=1;
}
else if(rt[count]>0)
{
rt[count]-=time_quantum;
time+=time_quantum;
}
if(rt[count]==0 && flag==1)
{
remain--;
printf("P[%d]\t|\t%d\t|\t%d\n",count+1,time-at[count],time-
at[count]-bt[count]);
wait_time+=time-at[count]-bt[count];
turnaround_time+=time-at[count];
flag=0;
}

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:

 Low overhead for decision making.


 Unlike other algorithms, it gives equal priority to all processes.
 Starvation rarely occurs in this process.

DISADVANTAGES:

 The efficiency of the system is decreased if the quantum value is low as


frequent switching takes place.
 The system may become unresponsive if the quantum value is high.

OVERALL PERFORMANCE DEPENDS ON

 Size of the time quantum

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:

1) Example 1: Time =20


Process Burst Time
P1 53
P2 17
P3 68
P4 24

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

 Average Turnaround Time:- (30+7+10)/3=15.67


 Waiting Time:-
P1=30-24=6
P2=7-3=4
P3=10-3=7

 Average Waiting Time:- (6+4+7)/3=5.67


Applications Of Micro Project
This can be used as a reference for people who want to learn Round
Robin Algorithm. This algorithm dramatically improves average
response time. By limiting each task to a certain amount of time, the
operating system can ensure that it can cycle through all ready tasks,
giving each one a chance to run.

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/

 some resources are from few text books

You might also like