All Programs are Written and Compiled in Dev C++. So, it may generate some error in case of other compilers and may need some modifications in program. Download Dev C++

Tuesday, 21 October 2014

FIFO Page Replacement Program

 To Implement FIFO Page Replacement

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,k,n,no,avail;
int a[50],frame[10],count=0;
cout<<"\n Enter The Number of Pages:";
cin>>n;
cout<<"\n Enter The Page Number :";
for(i=1;i<=n;i++)
        cin>>a[i];
cout<<"\n Enter The Number Of Frames :";
        cin>>no;
for(i=0;i<no;i++)
        frame[i]=-1;
j=0;
cout<<"\nRef_Str  \t Page_frames\n";
for(i=1;i<=n;i++)
{

cout<<a[i]<<"\t";
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++)
cout<<frame[k]<<"\t";
}
cout<<endl;
}
cout<<"Page Fault Is ="<<count;
getch();
}

No comments:

Post a Comment