#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int
n,flag=0,a[30],b[30],i,j,count=0,f,fault=0;
cout<<"\n**** FIFO page
replacement algorithm ****\n";
cout<<"\n enter no. of pages
";
cin>>n;
cout<<" \n enter the reference
string ";
for(i=0;i<n;i++)
cin>>b[i];
cout<<"enter frame :";
cin>>f;
for(i=0;i<n;i++)
{
for(j=0;j<f;j++)
{
if(a[j]==b[i])
{
flag=0;
break;
}
else
{
flag=1;
}
}
if(flag==1)
{
a[count]=b[i];
count++;
fault++;
if(count==f)
{
count= 0;
}
}
}
cout<<"total page faults are
:"<<fault;
getch();
}
No comments:
Post a Comment