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

Implementation of Round Robin Scheduling Algorithm Using C

This document implements round robin scheduling in C. It takes the arrival time and burst time of processes as input, then uses a time quantum of 1 unit to schedule the processes. It outputs the burst time, turnaround time, and waiting time of each process, and calculates the average turnaround and waiting times.

Uploaded by

Manav Gora
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
300 views3 pages

Implementation of Round Robin Scheduling Algorithm Using C

This document implements round robin scheduling in C. It takes the arrival time and burst time of processes as input, then uses a time quantum of 1 unit to schedule the processes. It outputs the burst time, turnaround time, and waiting time of each process, and calculates the average turnaround and waiting times.

Uploaded by

Manav Gora
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

Implementation of round robin scheduling algorithm using c.

#include<stdio.h>

void main()

int i, NOP, sum=0,count=0, y, quant, wt=0, tat=0, at[10], bt[10], temp[10];

float avg_wt, avg_tat;

printf(" Total number of process in the system: ");

scanf("%d", &NOP);

y = NOP;

for(i=0; i<NOP; i++)

printf("\n Enter the Arrival and Burst time of the Process[%d]\n", i+1);

printf(" Arrival time is: \t");

scanf("%d", &at[i]);

printf(" \nBurst time is: \t");

scanf("%d", &bt[i]);

temp[i] = bt[i];

printf("Enter the Time Quantum for the process: \t");

scanf("%d", &quant);

printf("\n Process No \t\t Burst Time \t\t TAT \t\t Waiting Time ");

for(sum=0, i = 0; y!=0; )

if(temp[i] <= quant && temp[i] > 0)

{
sum = sum + temp[i];

temp[i] = 0;

count=1;

else if(temp[i] > 0)

temp[i] = temp[i] - quant;

sum = sum + quant;

if(temp[i]==0 && count==1)

y--;

printf("\nProcess No[%d] \t\t %d\t\t\t\t %d\t\t\t %d", i+1, bt[i], sum-at[i], sum-at[i]-bt[i]);

wt = wt+sum-at[i]-bt[i];

tat = tat+sum-at[i];

count =0;

if(i==NOP-1)

i=0;

else if(at[i+1]<=sum)

i++;

else

i=0;

}
avg_wt = wt * 1.0/NOP;

avg_tat = tat * 1.0/NOP;

printf("\n Average Turn Around Time: \t%f", avg_wt);

printf("\n Average Waiting Time: \t%f", avg_tat);

Output:

/tmp/oAmSOSF4ms.o

Total number of process in the system: 3

Enter the Arrival and Burst time of the Process[1]

Arrival time is: 1

Burst time is: 2

Enter the Arrival and Burst time of the Process[2]

Arrival time is: 0

Burst time is: 3

Enter the Arrival and Burst time of the Process[3]

Arrival time is: 3

Burst time is: 2

Enter the Time Quantum for the process: 1

Process No Burst Time TAT Waiting Time

Process No[1] 2 2 0

Process No[2] 3 6 3

Process No[3] 2 4 2

Average Turn Around Time: 1.666667

Average Waiting Time: 4.000000

You might also like