Home » NO IDEA » First come First serve

First come First serve

Blog Stats

  • 15,880 hits
April 2013
M T W T F S S
« Mar   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

#include<stdio.h>

#include<stdlib.h>
struct process
{
int pid;
int wt,tt,bt;
}
p[100];
int main()
{
int tottt,totwt,avgtt,avgwt,i,j,n;

printf("\nEnter Number of process");
scanf("\n%d",&n);
for(i=1;i<=n;i++)
{
p[i].pid=i;
printf("\nEnter %dst Burst Time:",i);
scanf("\n%d",&p[i].bt);
}
p[1].wt=0;
p[1].tt=p[1].bt+p[1].wt;
i=2;
while(i<=n)
{
p[i].wt=p[i-1].tt;
p[i].tt=p[i].bt+p[i].wt;
i++;
}

totwt=tottt=0;
i=1;
printf("\n\t=============================");
printf("\n\tProcess id\tBT\tWT\tTT");
printf("\n\t=============================");
while(i<=n)
{
printf("\n\t%d\t%d\t%d\t%d\t",p[i].pid,p[i].bt,p[i].wt,p[i].tt);
totwt=p[i].wt+totwt;
tottt=p[i].tt+tottt;
i++;
}
totwt=totwt/n;
tottt=tottt/n;
printf("\n\n\n\tAVGWT\tAVGTT");
printf("\n\t%d\t%d",totwt,tottt);
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: