0% found this document useful (0 votes)
321 views3 pages

Round Robin

This document describes an experiment simulating the round robin CPU scheduling algorithm. It includes the theory behind round robin scheduling and an algorithm for implementing it. The program code provided implements round robin scheduling for a given set of processes, calculating their waiting times, turnaround times, and average waiting and turnaround times. The user is prompted to enter the number of processes and their burst times, as well as the time quantum, and the output displays the scheduling results.

Uploaded by

raj
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)
321 views3 pages

Round Robin

This document describes an experiment simulating the round robin CPU scheduling algorithm. It includes the theory behind round robin scheduling and an algorithm for implementing it. The program code provided implements round robin scheduling for a given set of processes, calculating their waiting times, turnaround times, and average waiting and turnaround times. The user is prompted to enter the number of processes and their burst times, as well as the time quantum, and the output displays the scheduling results.

Uploaded by

raj
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/ 3

OPERATING SYSTEMS LAB MANUAL

EXPERIMENT : 1c)

NAMEOF THE EXPERIMENT: Simulate the following CPU Scheduling Algorithms

c) Round Robin

AIM: Using CPU scheduling algorithms find the min & max waiting time.

HARDWARE REQUIREMENTS: Intel based Desktop Pc


RAM of 512 MB
SOFTWARE REQUIREMENTS:
Turbo C/ Borland C.

THEORY:

Round Robin:

Example of RR with time quantum=3

Process Burst time


aaa 4
Bbb 3
Ccc 2
Ddd 5
Eee 1

ALGORITHM
1. Start
2. Declare the array size
3. Read the number of processes to be inserted
4. Read the burst times of the processes
5. Read the Time Quantum
6. if the burst time of a process is greater than time Quantum then subtract time quantum form the burst time
Else
Assign the burst time to time quantum.
7.calculate the average waiting time and turn around time of the processes.
8. Display the values

9. Stop

1.
OPERATING SYSTEMS LAB MANUAL

PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
int st[10],bt[10],wt[10],tat[10],n,tq;
int i,count=0,swt=0,stat=0,temp,sq=0;
float awt=0.0,atat=0.0;
clrscr();
printf("Enter number of processes:");
scanf("%d",&n);
printf("Enter burst time for sequences:");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
st[i]=bt[i];
}
printf("Enter time quantum:");
scanf("%d",&tq);
while(1)
{
for(i=0,count=0;i<n;i++)
{
temp=tq;
if(st[i]==0)
{
count++;
continue;
}
if(st[i]>tq)
st[i]=st[i]-tq;
else
if(st[i]>=0)
{
temp=st[i];
st[i]=0;
}
sq=sq+temp;
tat[i]=sq;
}
if(n==count)
break;
}
for(i=0;i<n;i++)
{
wt[i]=tat[i]-bt[i];
swt=swt+wt[i];
stat=stat+tat[i];
}
awt=(float)swt/n;
atat=(float)stat/n;
printf("Process_no Burst time Wait time Turn around time");
for(i=0;i<n;i++)
printf("\n%d\t %d\t %d\t %d",i+1,bt[i],wt[i],tat[i]);
printf("\nAvg wait time is %f Avg turn around time is %f",awt,atat);
getch();
1.
OPERATING SYSTEMS LAB MANUAL

Input:
Enter no of jobs
4
Enter burst time
5
12
8
20
Output:

Bt wt tt
505
12 5 13
8 13 25
20 25 45
aw=10.75000
at=22.000000

VIVA QUESTIONS:
1.Round Robin scheduling is used in
(A)Disk scheduling. (B)CPU scheduling
(C)I/O scheduling. (D)Multitasking
2. What are the dis-advantages of RR Scheduling Algoritm?
3.What are the advantages of RR Scheduling Algoritm?
4.Super computers typically employ _______.
1 Real time Operating system 2 Multiprocessors OS
3 desktop OS 4 None of the above
5. An optimal scheduling algorithm in terms of minimizing the average waiting time of a given set of processes is
________.
1 FCFS scheduling algorithm 2 Round robin scheduling algorithm
3 Shortest job - first scheduling algorithm 4 None of the above

1.

You might also like