Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 q; // Data structure for FIFO /////////////////////////////// /////////////////////////////////////////////////////////////////// private Queue freeList; // Queue of free frame numbers /** * Creates a new MemoryManager. Builds a free list containing all frames. * @param table reference to the page table * @param sim reference to the simulator * @param gui reference to the user interface */ public MemoryManagerFIFO(PageTable table, Simulator sim) { this.table = table; this.sim = sim; /////////////////////////////////////////////////////////////// /////////////////////////////// q = new LinkedList(); // Create data structure for FIFO /////////////////////////////// /////////////////////////////////////////////////////////////// freeList = new LinkedList(); for(int i=0; i

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 Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions