Lab Programs
Lab Programs
Lab Programs
for(i=0;i<n;i++)
{
if(i==0)
star[i]=arr[i];
else
star[i]=finish[i-1];
wt[i]=star[i]-arr[i];
finish[i]=star[i]+bur[i];
tat[i]=finish[i]-arr[i];
}
printf("\nPName Arrtime Burtime WaitTime Start TAT Finish");
for(i=0;i<n;i++)
{
printf("\n%s\t%3d\t%3d\t%3d\t%3d\t%6d\t%6d",pn[i],arr[i],bur[i],wt[i],star[i],tat[i],finis
h[i]);
totwt+=wt[i];
tottat+=tat[i];
}
printf("\nAverage Waiting time:%f",(float)totwt/n);
printf("\nAverage Turn Around Time:%f",(float)tottat/n);
getch();
return 0;
}
OUTPUT:
Input:
Enter the number of processes: 3
Enter the Process Name, Arrival Time & Burst Time: p1 2 4
Enter the Process Name, Arrival Time & Burst Time: p2 3 5
Enter the Process Name, Arrival Time & Burst Time: p3 1 6
Output:
PName Arrtime Burtime WaitTime Srart TAT Finish
p3 1 6 0 1 6 7
p1 2 4 5 7 9 11
p2 3 5 8 11 13 16
Average Waiting Time: 4.3333333
Average Turn Around Time: 9.33333333
PROGRAM-2
Input:
Enter the Number of Pages: 12
Enter 12 Page Numbers:
232152453252
Output:
2 2-> F
3 23-> F
2 23
1 231-> F
5 251-> F
2 251
4 254-> F
5 254
3 354-> F
2 352-> F
5 352
2 352
No of faults: 7
PROGRAM-7