Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int bt[20],wt[20], tat[20], p[20],ct[57], i, j, n,temp=0,max,t;
- float wtavg, tatavg;
- printf("Enter number of process : ");
- scanf("%d", &n);
- for (i=0; i<n; i++)
- {
- // p[i]=i;
- printf("Enter burst time for process %d: ", i);
- scanf("%d", &bt[i]);
- ct[i]=bt[i];
- }
- printf("Enter time_slice : ");
- scanf("%d", &t);
- max=bt[0];
- for (i=1; i<n; i++)
- {
- if (max<bt[i])
- max=bt[i];
- }
- for (j=0; j<(max/t)+1; j++)
- {
- for (i=0; i<n; i++)
- {
- if(bt[i]!=0)
- {
- if(bt[i]<=t)
- {
- tat[i]=temp+bt[i];
- temp=tat[i];
- bt[i]=0;
- }
- else
- {
- bt[i]=bt[i]-t;
- temp=temp+t;
- }
- }
- }
- }
- printf("\t Process \t BurstTime \t WaitingTime \t TurnaroundT");
- for(i=0; i<n; i++)
- {
- printf("\n\t p%d \t\t%d \t\t%d \t\t%d", i, ct[i], tat[i]-ct[i], tat[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement