Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // operating systems ----FCFS algorithm---------
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- void main()
- {
- int count=1,n=0,pid[100],at[100],et[100],ct[100],wt[100],tt[100],i=0,choice=1;
- float avgwt=0.0,avgtt=0.0;
- clrscr();
- while(choice==1)
- {
- printf("\nenter arrival time:-");
- scanf("%d",&at[i]);
- printf("\nenter execution time:-");
- scanf("%d",&et[i]);
- if(i==0)
- ct[i]=et[i];
- else
- ct[i]=ct[i-1]+et[i];
- wt[i]=ct[i]-(et[i]+at[i]);
- tt[i]=ct[i]-at[i];
- i++;
- printf("more processes 1. yes 2. no ");
- scanf("%d",&choice);
- }
- printf("pid\tAT\tET\tCT\tWT\tTT\n");
- while(n!=i)
- {
- printf("%d\t",count++);
- printf("%d\t",at[n]);
- printf("%d\t",et[n]);
- printf("%d\t",ct[n]);
- printf("%d\t",wt[n]);
- printf("%d\n",tt[n]);
- n++;
- }
- n=0;
- while(n!=i)
- {
- avgwt=wt[n]+avgwt;
- avgtt=tt[n]+avgtt;
- n++;
- }
- printf("\n*******average waiting time is %f******\n",(avgwt/n));
- printf("*******average turnaound time is %f******\n",(avgtt/n));
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment