This is JAVA programing problem. Please give me all necessary screenshot and comments. (I use Eclipse) Thanks
Write a program that implements the FIFO, LRU, and Optimal page replacement algorithms presented in chapter 8 of your text. First generate a random page-reference string (this should be 20 entries long) where page numbers range from 0 to 9. Apply the random page-reference string to each algorithm, and record the number of page faults incurred by each algorithm. Implement the replacement algorithms so that the number of page frames goes from 1 to 7 and you must compute the page fault for each of these frame numbers. Record the number of page faults with each of these different page frames numbers and each of the different algorithms. Assume that demand paging is used. Remember to count the first time a page comes in, as this is a page fault in demand paging.
Then do the same procedure, except use the following page-reference string instead of the random one:
0,7,1,1,2,0,8,9,0,3,0,4,5,6,7,0,8,9,1,2 and then lastly do it with the page-reference string: 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1
Note this last string appears in examples in your text on pages 387-390 (use this string to verify some of your code).
Have separate clearly marked classes or methods for LRU, FIFO, and Optimal replacement algorithms. Also have comments within your code.
Make certain to have your name, date, assignment number, and a brief description of the program at the top of your main method.
Your output should be in the following format (repeated seven times, one for each number of page frames, and the set of seven repeated three times, one for each of the three page-reference strings):
For x page frames, and using string page reference string nnnnnnnnnnnnnn:
FIFO had ### page faults.
LRU had ### page faults.
Optimal had ### page faults.
Where ### is the number of page faults, x is the number of page frames, and nnnnnn is the page-reference string.
Remember to remove or turn off all of any debug output before you generate the output to send to me. Do not make the program interactive, it should run through the three strings with no human interaction.
Your name and the assignment number must appear at the top your output file by your program.
Note the Optimal algorithm is much harder than either of the other two.
Look for errors:
For x page frames, and using string page reference string nnnnnnnnnnnnnn:
FIFO had ### page faults.
LRU had ### page faults.
Optimal had ### page faults.
Program:
// Define a header files
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
// Implement Class Replacement
public class Replacement
{
// define a read input
static Scanner scan=new Scanner(System.in);
int no_pages, page[], no_frames, frames[], faults, count;
double rate;
// define constructor
public Replacement() throws IOException
{
// Read Number of Pages
System.out.println("Enter Number of Pages");
no_pages=scan.nextInt();
page=new int[no_pages];
// Read Number of Frames
System.out.println("Enter Number of Frames");
no_frames=scan.nextInt();
frames=new int[no_frames];
count=1;
}
// Function to Reset the Frame Array
void Frame_reset()
{
int j;
for(j=0;j<no_frames;j++)
frames[j]=0;
faults=0;
count=1;
}
// Page Reference Randomly Generating
void Page_reference() throws IOException
{
int i;
// Rabdomly Generating the String
for(i=0;i<no_pages;i++)
{
page[i]=0 + (int)(Math.random() * ((9 - 0) + 1));
}
System.out.println("The Reference String is");
// Printing the String
for(i=0;i<no_pages;i++)
{
System.out.print(page[i]);
}
System.out.println();
for(i=0;i<no_frames;i++)
frames[i]=-1;
}
// FIFO Replacement
void FIFO_repacement()
{
int i,j,k=0;
// Reset the frame set
Frame_reset();
boolean fd=false;
for(i=0;i<no_pages;i++)
{
for(j=0;j<no_frames;j++)
{
if(page[i]==frames[j])
fd=true;
}
if(fd==false)
{
frames[k]=page[i];
if(k==no_frames-1)
k=0;
else
k++;
faults++;
}
Display();
fd=false;
}
System.out.println("Number of Page Faults = "+faults);
System.out.println("Fault Rate = "+(faults/no_pages));
}
// LRU Replacement
void LRU_replacement()
{
int i,j,dr[],max;
Frame_reset();
dr=new int[no_frames];
boolean found=false;
for(i=0;i<no_pages;i++)
{
for(j=0;j<no_frames;j++)
dr[j]++;
for(j=0;j<no_frames;j++)
{
if(page[i]==frames[j])
{
found=true;
dr[j]=0;
}
}
if(found==false)
{
max=0;
for(j=0;j<no_frames;j++)
{
if(dr[j]>dr[max])
max=j;
}
frames[max]=page[i];
dr[max]=0;
faults++;
}
Display();
found=false;
}
System.out.println("Number of Page Faults = "+faults);
System.out.println("Fault Rate = "+(faults/no_pages));
}
// Disply Function
void Display()
{
int i;
System.out.print("Page Frame "+count+" :");
for(i=0;i<no_frames;i++)
{
if(frames[i]==-1)
System.out.print(" -");
else
System.out.print(" "+frames[i]);
}
System.out.print(" o_pages");
count++;
}
public static void main(String[] args) throws IOException{
int me;
String cha;
Replacement p=new Replacement();
p.Page_reference();
do
{
System.out.println("1. FIFO");
System.out.println("2. LRU");
System.out.println("Enter option");
me=scan.nextInt();
switch(me)
{
case 1: p.FIFO_repacement();
break;
case 2: p.LRU_replacement();
break;
default: System.out.println("Invalid input");
}
System.out.println("Enter Y to continue");
scan.nextLine();
cha=scan.nextLine();
}
while(cha.compareToIgnoreCase("y")==0);
}
}
Output:
This is JAVA programing problem. Please give me all necessary screenshot and comments. (I use Ecl...
Java Looking for some help on getting this started. Directions below. Operating systems designers have long used simulation as an inexpensive way to test new algorithms. In this assignment you write a Java program that prompts the user for simulation data then runs a selected page replacement algorithm on that system, reporting frame assignments and total page faults. Instructions Your program will prompt the user first for the number of frames to be used in the simulation, then for a...
Consider the following page reference string: A C B D B A E F B F A G E F A Assuming demand paging with four frames, how many page faults would occur for the following replacement algorithms? Remember that all frames are initially empty, so your first unique pages will cost one fault each. Show all of your works. LRU replacement FIFO replacement Optimal (MIN) replacement
Consider the following page reference string: 5, 3,7,5, 3, 6, 1, 0,4,6,2,0,1,2,7,3,1,4,7,2 Assuming demand paging with three frames, how many page faults would occur for the following replacement algorithms!? LRU replacement FIFO replacement Optimal replacement
Question 7 30 pts Consider the following page reference string: {1,2,3,4,1,5,6,2,1,2,3,7,6,3} Assume that the system has 4 page frames allocated to these 7 pages. Follow the page placement and replacement using the following three replacement algorithms: • LRU replacement • FIFO replacement • Optimal replacement How many page faults will occur for these three algorithms? Assume that all frames are initially empty, so your first unique pages will all cost one fault each USE ENCLOSED TABLES! Show all calculations in...
A system has 5 frames. For each of the algorithms below give the number of pages faults for the reference string 43214573654632714. Show all your work. (a) FIFO (b) Optimal Algorithm (c) LRU (d) Working set Algorithm. Assume that there are 3 page reference between clock ticks. Also in case of a tie the page with the lowest number is paged out.
Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6. How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each. • LRU replacement • FIFO replacement • Optimal replacement
Consider the following page reference string for a specific process: 7, 2, 3, 1, 2, 5, 3, 4, 6, 7, 7, 1, 0, 5, 4, 6, 2, 3, 0, 1 Assuming demand paging with 3 frames, determine the page fault rate for each of the following page replacement algorithms: a. LRU replacement b. FIFO replacement c. Optimal replacement
Consider the following page reference string: 1, 0, 3, 2, 6, 4, 5, 0, 1, 7, 7, 6, 4, 3, 5, 2, 1, 3, 2, 7 Assuming demand paging with three frames, how many page faults would occur for the following replacement algorithms? Show your work. (a) LRU replacement (b) FIFO replacement (c) Optimal replacement
9.3 (3 points for correct answer, 7 points for steps) Consider the following page reference string: 6, 1, 5, 5, 4, 6, 2, 6, 0 , 1, 7, 2, 3, 1, 4, 6, 7, 2, 5, 2,. Assuming demand paging with three frames, how many page faults would occur for the following replacement algorithms? • LRU replacement • FIFO replacement • Optimal replacement
Write a program that implements the FIFO, Optimal, MFU, and LRU page-replacement algorithms. Given a page-reference string, where page numbers range from 0 to 9, apply the page-reference string to each algorithm, and output the number of page faults incurred by each algorithm. Write your code so that the number of page frames in the page table can vary from 1 to 10. 1.0 Functional Requirements 1.1: Your program shall be run with the following: ./a.out Example: ./a.out datafile.txt 1.2:...