Question: #define N 4 int main ( ) { static int pn [ N ] = { 3 , 2 , 1 , 4 } ,

#define N 4int main(){ static int pn[N]={3,2,1,4}, at[N]={3,2,0,1}, bt[N]={25,5,10,15}; int wt[N], tt[N], i, j, sum =0; float avgwt =0.0, avgtt =0.0; printf("\tFCFS Scheduling Policy
"); printf("------------------------------------------------------------
"); printf("| pn\t| at\t| bt\t| wt\t| tt\t|
"); printf("------------------------------------------------------------
");// Calculate waiting time wt[0]=0; // First process has zero waiting time for (i =1; i < N; i++){ wt[i]=0; for (j =0; j < i; j++){ wt[i]+= bt[j];} wt[i]-= at[i]; if (wt[i]<0) wt[i]=0;// No negative waiting time}// Calculate turnaround time and sum of waiting/turnaround times for (i =0; i < N; i++){ tt[i]= bt[i]+ wt[i]; avgwt += wt[i]; avgtt += tt[i]; printf("|%d\t|%d\t|%d\t|%d\t|%d\t|
", pn[i], at[i], bt[i], wt[i], tt[i]);} printf("------------------------------------------------------------
");// Calculate and display average waiting time and turnaround time avgwt /= N; avgtt /= N; printf("Average Waiting Time: %.2f
", avgwt); printf("Average Turnaround Time: %.2f
", avgtt); return 0;} do it with Gantt chart

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!