Write a Java program that implements the FIFO and LRU page replacement algorithms in the way that we discussed them in class. Ask the user for a 14-digit reference string consisting of the digits from...

1 answer below »

Write a Java program that implements the FIFO and LRU page replacement algorithms in the way that we discussed them in class.


Ask the user for a 14-digit reference string consisting of the digits from 0-7. They can be any random digits from 0-7, not all the digits need to be included, and they can be in any order. Here's an example of one such string for you to use0 1 3 0 2 1 4 2 3 6 5 1 6 0. Note that the data type for this could be eitherStringorint(an array would likely be helpful here).


Randomly set the number of frames from the range 1 - 5, inclusive (Hint: use Java's built inRandomclass).


Display the number of page faults for each algorithm.


Some hints:



  • The reference string can either beStringorint. It seemed easier to store the values into an array.

  • Start with a number that you know first. For example, using the example reference string given above, I used 3 frames to test it. I did it on paper first and then checked it against what the program output. As you'll see in the example below, for testing purposes, I had it print out the frames as it went through. Once you have it working for the hardcoded number of frames, randomize it and see if your code works for other frames.

  • Your code should be able to work with other reference strings and number of frames.

  • AnArrayListseems to be good for representing a frame since you can insert at the front.

  • Your algorithm is important. Start out by writing your set of steps in your java application as comments. I would prefer you give me just a file that has nothing but comments in it than for you to copy something that you don't understand from the internet.

  • Please don't consult Chegg or stackoverflow or any of the other places. You'll end up with some code that isn't exactly what I asked you to do (because they know more than I expect you to know and will do fancy things and I will be able to figure out that you didn't do it on your own). You'll get more points by giving me something that doesn't work than for you to insult me by getting your largely incorrect answer from somewhere else, plus, I won't have to turn you in to Community Standards for cheating.


Here's some sample output (user input in bold):


Please enter a 14 digit reference string containing only the digits 0-7, in any order: 01302142365160 Reference String: 0 1 3 0 2 1 4 2 3 6 5 1 6 0 Frame state: [0] 1 faults Frame state: [1, 0] 2 faults Frame state: [3, 1, 0] 3 faults Frame state: [3, 1, 0] 3 faults Frame state: [2, 3, 1] 4 faults Frame state: [2, 3, 1] 4 faults Frame state: [4, 2, 3] 5 faults Frame state: [4, 2, 3] 5 faults Frame state: [4, 2, 3] 5 faults Frame state: [6, 4, 2] 6 faults Frame state: [5, 6, 4] 7 faults Frame state: [1, 5, 6] 8 faults Frame state: [1, 5, 6] 8 faults Frame state: [0, 1, 5] 9 faults Number of page faults with 3 frames for FIFO: 9  Frame state: [0] 1 faults Frame state: [1, 0] 2 faults Frame state: [3, 1, 0] 3 faults Frame state: [0, 3, 1] 3 faults Frame state: [2, 0, 3] 4 faults Frame state: [1, 2, 0] 5 faults Frame state: [4, 1, 2] 6 faults Frame state: [2, 4, 1] 6 faults Frame state: [3, 2, 4] 7 faults Frame state: [6, 3, 2] 8 faults Frame state: [5, 6, 3] 9 faults Frame state: [1, 5, 6] 10 faults Frame state: [6, 1, 5] 10 faults Frame state: [0, 6, 1] 11 faults Number of page faults with 3 frames for LRU: 11

Note that the above output uses aStringas the data type for the reference string. To use anint, consider adding spaces between the digits (0 1 3 0 2 1 4 2 3 6 5 1 6 0).



Only the total number of page faults for each algorithm is necessary. The other output I have here (i.e., frame state) was simply for debugging purposes









Please make it as simple as possible.If it's overly advanced the professor will know someone else did it.

Answered 1 days AfterApr 30, 2022

Answer To: Write a Java program that implements the FIFO and LRU page replacement algorithms in the way that we...

Uhanya answered on May 01 2022
85 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here