#include<stdio.h>
int refstring[20],pt[10],nof,nor;
void accept()
{
int i;
printf("Enter the reference string:");
for(i=0;i<nor;i++)
{
printf("[%d]=",i+1);
scanf("%d",&refstring[i]);
}
}
int search(int s)
{
int i;
for(i=0;i<nof;i++)
if(pt[i]==s)
return(i);
return(-1);
}
void FIFO()
{
int i,j,k=0,faults=0;
for(i=0;i<nor;i++)
{
printf("%2d||\t",refstring[i]);
if(search(refstring[i])==-1)
{
pt[k]=refstring[i];
for(j=0;j<nof;j++)
{
printf("%d\t",pt[j]);
}
faults++;
k=(k+1)%nof;
printf("page faults");
}
printf("\n");
}
printf("total page faults %d\n",faults);
}
int main()
{
clrscr();
printf("Enter the length of the reference string:");
scanf("%d",&nor);
printf("Enter the no. of frames:");
scanf("%d",&nof);
accept();
FIFO();
getch();
}

Post a Comment

Previous Post Next Post