Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

According to this instruction please edit this code i provide you. Thanks Write a program that implements the FIFO, LRU, and Optimal page replacement algorithms

According to this instruction please edit this code i provide you. 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.

Place the following in the Dropbox for assignment #5 in D2L: a copy of your source code, output file from your run, and your observations file.

Do not use screen shots for you data file.

Place your observations (how do the different methods compare for the page-replacement strings) in another attached text or word file and make certain that your name and the assignment number are at the top of your observations file. Remember to place the approximate number of hours you spent on this assignment in your observations file.

Note the Optimal algorithm is much harder than either of the other two.

*****************************************************************************************************************

import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; // Define a header files import java.io.IOException; import java.util.Random; import java.io.PrintWriter; import java.util.Scanner; import HomeWork03.DemoLinkedList; // Implement Class Replacement public class PageReferenceString{// 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 PageReferenceString() 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions