in operating system subject in goorm web modify the bellow code to add this arrival time process arrival time p1

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

in operating system subject in goorm web modify the bellow code to add this arrival time process arrival time p1

Post by answerhappygod »

in operating system subject in goorm web modify the
bellow code to add this arrival time
process arrival time
p1 0.0
p2 0.4
p3 1.0
#include<stdio.h>
int main()
{
int i, n ;
float bt[10],wt[10],tt[10],awt, att;
awt=att=0.0;
printf("\nEnter the number of jobs\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter the burst time for job %d:",i+1);
scanf("%f",&bt);
// first process
if (i==0)
{
wt[0]=0.0; //assign waiting time zero
tt[0]=bt[0]; //turn around time is the burst time itself
}
else
// for other processes
{
wt=tt[i-1];
tt=tt[i-1]+bt;
}
}
printf("\n\tJob\t\tBurst Time \t\tTurnAround Time \t\tWaiting
time\n");
for(i=0;i<n;i++)
{
printf("\n\t%d\t\t%f\t\t%f\t\t%f",i+1,bt,tt,wt);
awt=awt+wt;
att=att+tt;
}
awt=awt/n; //average waiting time
att=att/n; //average turnaround time
printf("\nAverage Waiting Time is %f",awt);
printf("\nAverage TurnAround Time is %f",att);
return 0;
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply