The following is to be written in C. Compare the performance of the following pa
ID: 3857556 • Letter: T
Question
The following is to be written in C. Compare the performance of the following page replacement algoirthm: FIFO. You will be provided with a .dat file containing the virtual addresses that are being referenced by a single program (a process). Run your program with the following parameters:
Page Size: 512, 1024, 2048 (words)
Number of frames allocated to the process: 4, 8, 12
(So you will have 9 runs, with each page size and number of frames combination. Each run contains statistics that should be printed in the following format)
Page Size # of Pages Page Replacement Algorithm. Page Fault Percentage.
Explanation / Answer
Program:
#include<stdio.h>
int main()
{
int i,j,n,a[50],frame[10],no,k,avail,count=0;
printf(" ENTER THE NUMBER OF PAGES: ");
scanf("%d",&n);
printf(" ENTER THE PAGE NUMBER : ");
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
printf(" ENTER THE NUMBER OF FRAMES :");
scanf("%d",&no);
for(i=0;i<no;i++)
frame[i]= -1;
j=0;
printf(" ref string page frames ");
for(i=1;i<=n;i++)
{
printf("%d ",a[i]);
avail=0;
for(k=0;k<no;k++)
if(frame[k]==a[i])
avail=1;
if (avail==0)
{
frame[j]=a[i];
j=(j+1)%no;
count++;
for(k=0;k<no;k++)
printf("%d ",frame[k]);
}
printf(" ");
}
printf("Page Fault Is %d",count);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.