7th(Priority) s
7th(Priority) s
Practical-07
Aim- List of processes / jobs along with their arrival times, priority value & 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 Priority CPU scheduling policy.
Code-
bt[i]=bt[j];
bt[j]=x; x=p[i];
p[i]=p[j];
p[j]=x;
}
} } w[0]=0;
awt=0;
t[0]=bt[0];
atat=t[0];
for(i=1;i<n;i++)
{ w[i]=t[i-1];
awt+=w[i];
t[i]=w[i]+bt[i];
atat+=t[i];
}
System.out.print("\n\nProcess \t Burst Time \t Wait Time \t Turn Around Time Priority \n");
for(i=0;i<n;i++)
System.out.print("\n "+p[i]+"\t\t "+bt[i]+"\t\t "+w[i]+"\t\t "+t[i]+"\t\t "+pp[i]+"\n");
awt/=n; atat/=n;
System.out.print("\n Average Wait Time : "+awt);
System.out.print("\n Average Turn Around Time : "+atat);
}
}
Shahabuddin Ahmad 11232945 I
Output-