Question
Using the Page Replacement simulation from the previous assignment, implement ONE of the following algorithms: 1) Optimal 2) Second Chance Implement only ONE of the
Using the Page Replacement simulation from the previous assignment, implement ONE of the following algorithms:
1) Optimal 2) Second Chance
Implement only ONE of the above algorithms by editing the MemoryManager class. You will not have to modify any other class in the simulation.
Here are some simulation methods you can call as part of your implementation, if necessary:
sim.getAccesses() - returns an int array containing the sequence of page references.
sim.getCurrentAccess() - returns an index for the array returned by the method above; the index identifies the current page reference.
sim.getFrameTable() - returns an int array containing the page numbers of the resident pages.
sim.getNumberFrames() - returns the number of physical pages in the simulation (typically 4)
table.getEntry(pageNumber) - returns the Page Table entry (a PTEntry object) for the given page number.
entry.isAccessed() - returns true if the Accessed/Second Chance bit is set; assumes "entry" is the variable name for the PTEntry object retrieved from the Page Table.
entry.setAccessed(boolean) - sets the Accessed/Second Chance but for the Page Table entry: true for 1 and false for 0.
HINT: Almost all of the work will be in the evict() method.
USE the optimal this is this is the code for FIFO
import java.util.LinkedList; import java.util.Queue; /** * This class contains the Memory Management methods called by the Simulator. * * Currently, this class implements the FIFO page replacement algorithm. * Modify this class with your page replacement algorithm. * * @author Adam Fischbach * @version Fall 2013 * */ public class MemoryManagerFIFO implements MemoryManager { private PageTable table; // Reference to the page table private Simulator sim; // Reference to the simulator /////////////////////////////////////////////////////////////////// /////////////////////////////// private Queue
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started