0% found this document useful (0 votes)
6 views2 pages

123

The document contains a C program that implements a scheduling algorithm to calculate waiting time and turnaround time for processes. It sorts processes based on their arrival times and computes the total waiting and turnaround times, displaying the results for each process. Finally, it calculates and prints the average waiting time and average turnaround time.

Uploaded by

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

123

The document contains a C program that implements a scheduling algorithm to calculate waiting time and turnaround time for processes. It sorts processes based on their arrival times and computes the total waiting and turnaround times, displaying the results for each process. Finally, it calculates and prints the average waiting time and average turnaround time.

Uploaded by

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

#include <stdio.

h>

int main() {

int pr[5]={0,1,2,3,4},at[5]={3,6,0,6,5},bt[5]={5,4,3,2,4};

int Ttat=0,tat[5],Twt=0,wt[5],i,j,t=0,temp;

for(i=0;i<=3;i++){

for(j=i+1;j<=4;j++)

if(at[i]>at[j]){

temp=at[i];

at[i]=at[j];

at[j]=temp;

temp=pr[i];

pr[i]=pr[j];

pr[j]=temp;

temp=bt[i];

bt[i]=bt[j];

bt[j]=temp;

for(i=0;i<=4;i++){

wt[i]=t-(at[i]);

Twt+=wt[i];
t=t+bt[i];

tat[i]=t-at[i];

Ttat+=tat[i];

printf("\n process \t burst time \t waiting time \t turn around time");

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

printf("\n %d \t\t \t %d \t\t \t %d \t\t \t %d \t\t",pr[i],bt[i],wt[i],tat[i]);

printf("\n Average waiting time =%f \t Average Turn around Time =%f",Twt/5.0,Ttat/5.0);

return 0;

You might also like