Page Replacement Policies


import java.io.*;
class pagereplacement
{
public static void main(String a[])throws IOException
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
int mf[]=new int[3];
String wish;
int i,j,k,msize=3,fault;
int x[];

System.out.println("Enter the total no. of pages ");
int n=Integer.parseInt(b.readLine());
x=new int[n];
System.out.println("Enter the page nos.");
for(i=0;i3)
index=0;
if(j>3)
{
for(i=j;i<(j+3)&&j<(x.length-3);i++) for(k=0;k=3)
index=0;
if(flag)
{if(mf[index]!=0)
{fault++;}
mf[index]=temp;
index++;
}
System.out.println("Main frame is......");
for(i=0;i>"+mf[i]);
}
System.out.println("Number of hits is"+hit);
System.out.println("Number of faults is"+fault);
break;
default :System.out.println("Wrong Choice!!!!");
}
System.out.println("Do you want to continue(y/n):");
wish=b.readLine();
}
while(wish.equalsIgnoreCase("y"));
}

}

0 comments :