Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void main()
- {
- int bt[20], wt[20], tat[20], i, n, p[20], k, prio[20];
- float wtavg, tatavg, watag;
- printf ("Enter the no. of process: ");
- scanf("%d",&n);
- printf ("\n");
- for(i=0; i<n; i++)
- {
- p[i]=i;
- printf ("Enter the information for process %d : ", i);
- printf ("\nEnter burst time: ");
- scanf ("%d", &bt[i]);
- printf ("Enter priority: ");
- scanf ("%d", &prio[i]);
- printf ("\n");
- }
- for (i=0; i<n; i++)
- {
- for(k=i+1; k<n; k++)
- {
- if(prio[i]>prio[k])
- {
- (prio[i] ^= prio[k]), (prio[k] ^= prio[i]), (prio[i] ^= prio[k]);
- (bt[i] ^= bt[k]), (bt[k] ^= bt[i]), (bt[i] ^= bt[k]);
- (p[i] ^= p[k]), (p[k] ^= p[i]), (p[i] ^= p[k]);
- }
- }
- }
- wt[0] = 0;
- tat[0] = bt[0];
- for(i=1; i<n; i++)
- {
- wt[i]=tat[i-1];
- tat[i]= wt[i]+bt[i];
- }
- printf("\t Process \t Priority \t Burst Time \t WT Time \t TA Time");
- for(i=0; i<n; i++)
- {
- printf("\n\t p%d \t\t%d \t\t%d \t\t%d \t\t%d", p[i], prio[i], bt[i], wt[i], tat[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement