Facebook
From f, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 155
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct fcfs
  5. {
  6.  int pid;
  7.  int btime;
  8.  int wtime;
  9.  int ttime;
  10. }p[10];
  11.  
  12. int main()
  13. {
  14. int i,n,j;
  15. struct fcfs tmp;
  16. int totwtime=0,tottime=0;
  17.  
  18. printf("Enter no of Processes n");
  19. scanf("%d",&n);
  20. for(i=0;i<n;i++)
  21. {
  22.   p[i].wtime=p[i-1].wtime+p[i-1].btime;
  23.   p[i].ttime=p[i].wtime+p[i].btime;
  24.  
  25.   tottime = tottime+p[i].ttime;
  26.   totwtime = totwtime+p[i].wtime;
  27. }
  28.  
  29. printf("Total Waiting time: %d n",totwtime);
  30. printf("Average Waiting time: %d n", totwtime/n);
  31. printf("Total turnaround time: %d n", tottime);
  32. printf("Average turnaround time: %d n", tottime/n);
  33.  
  34. }
  35.