Exp - 4 Os
Exp - 4 Os
Exp - 4 Os
AIM :- List of processes / jobs along with their arrival times &
CPU burst times is given. Write a program to print the total
waiting time, average waiting time, total turnaround time,
average turnaround time & Gantt Chart using First Come First
Serve(FCFS) CPU scheduling policy.
PROGRAM:-
#include<stdio.h>
int main(){
int bt[10]={0},at[10]={0},tat[10]={0},wt[10]={0},ct[10]={0};
int n,sum=0;
float totalTAT=0,totalWT=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&at[i]);
scanf("%d",&bt[i]);
printf("\n");
}
for(int j=0;j<n;j++)
sum+=bt[j];
ct[j]+=sum;
for(int k=0;k<n;k++)
tat[k]=ct[k]-at[k];
totalTAT+=tat[k];
for(int k=0;k<n;k++)
wt[k]=tat[k]-bt[k];
totalWT+=wt[k];
printf("Solution: \n\n");
for(int i=0;i<n;i++)
{
printf("P%d\t %d\t %d\t %d\t %d\t %d\n",i+1,at[i],bt[i],ct[i],tat[i],wt[i]);
printf("Average WT = %f\n\n",totalWT/n);
return 0;
OUTPUT:-