Question: Task 1 package memory; import java.io . FileNotFoundException; import java.io . IOException; import java.io . R 1 . Download the code from . and make
Task package memory;
import java.ioFileNotFoundException;
import java.ioIOException;
import java.ioR
Download the code from and make sure that you can compile it Note that when running the code for the first time, you will get index out of bounds, this due to that getPageNumber getPageOffset and handlePageFault is not implemented in MemoryManager.class.
Note that when running the code for the first time, you will get index out of bounds, this due to that getPageNumber getPageOffset and handlePageFault is not implemented in MemoryManager.class.
Implement the handlePageFault method such that a page is loaded into a free frame in the physical memory in case of page fault.
Run the application and testCaseOne that is supplied in the Seminarclass. to verify your results.
public class Seminar
private static final String BACKINGSTOREFILE "resourcesBACKINGSTORE.bin";
private static final int PAGESIZE ;
private static final int NUMBEROFPAGES ;
private static final int NUMBEROFFRAMES;
private static final int NUMBEROFFRAMES;
private static final int NUMBEROFFRAMES;
private static final int NUMBEROFFRAMES;
public static final int NOPAGEREPLACEMENT ;
public static final int FIFOPAGEREPLACEMENT ;
public static final int LRUPAGEREPLACEMENT ;
public static void mainString args
When running the code for the first time, you will get index out of bounds This is due to that getPageNumber getPageOffset and handlePageFault is not implemented in MemoryManager.class
testTaskOne; testTaskTwo; Uncomment to run tc testTaskThree; Uncomment to run tc
private static void testTaskOne
System.out.printlnTesting task one";
MemoryManager memoryManager new MemoryManagerNUMBEROFPAGES, PAGESIZE, NUMBEROFFRAMES BACKINGSTOREFILE, NOPAGEREPLACEMENT;
MemoryProcess mp new MemoryProcessresourcesaddressestxt memoryManager;mpcallMemory; int numberOfPageFaults memoryManager.getNumberOfPageFaults;
System.out.printlnNumber of page faults: numberOfPageFaults;
System.out.printlnExpected: ;
ifnumberOfPageFaults
System.out.printlnPass;
else
System.out.printlnAssertion Fail";
System.out.println;
private static void testTaskTwo
Systemout.printlnTesting task two";
int numberOfPageFaults getNumberOfPageFaultsFifoNUMBEROFFRAMES;
verifyFifonumberOfPageFaults NUMBEROFFRAMES;
numberOfPageFaults getNumberOfPageFaultsFifoNUMBEROFFRAMES; verifyFifonumberOfPageFaults NUMBEROFFRAMES; numberOfPageFaults getNumberOfPageFaultsFifoNUMBEROFFRAMES; verifyFifonumberOfPageFaults NUMBEROFFRAMES;
private static void testTaskThree
System.out.printlnTesting task three";
int numberOfPageFaults getNumberOfPageFaultsLRUNUMBEROFFRAMES; verifyLRUnumberOfPageFaults NUMBEROFFRAMES; numberOfPageFaults getNumberOfPageFaultsLRUNUMBEROFFRAMES; verifyLRUnumberOfPageFaults NUMBEROFFRAMES; numberOfPageFaults getNumberOfPageFaultsLRUNUMBEROFFRAMES; verifyLRUnumberOfPageFaults NUMBEROFFRAMES;
private static void verifyFifoint numberOfPageFaults, int expectedPageFaults, int numberOfFrames
System.out.printlnFIFO with numberOfFrames frames";
System.out.printlnNumber of page faults: numberOfPageFaults;
System.out.printlnExpected: expectedPageFaults;
ifnumberOfPageFaults expectedPageFaults
System.out.printlnPass;
else
System.out.printlnAssertion Fail";
System.out.println;
private static void verifyLRUint numberOfPageFaults, int expectedPageFaults, int numberOfFrames
Systemout.printlnLRU with numberOfFrames frames";
System.out.printlnNumber of page faults: numberOfPageFaults;
System.out.printlnExpected: expectedPageFaults;
ifnumberOfPageFaults expectedPageFaults
System.out.printlnPass;
else
System.out.printlnAssertion Fail";
System.out.println;
private static void verifyLRUint numberOfPageFaults, int expectedPageFaults, int numberOfFrames
Systemout.printlnLRU with numberOfFrames frames";
System.out.printlnNumber of page faults: numberOfPageFaults;
System.out.printlnExpected: expectedPageFaults;
ifnumberOfPageFaults expectedPageFaults
System.out.printlnPass;
else
System.out.printlnAssertion Fail";
System.out.println; private static int getNumberOfPageFaultsFifoint numberOfFramesMemoryManager memoryManager new MemoryManagerNUMBEROFPAGES, PAGESIZE, numberOfFrames, BACKINGSTOREFILE, FIFOPAGEREPLACEMENT; MemoryProcess mp new MemoryProcessresourcesaddressestxt memoryManager; mpcallMemory; return memoryManager.getNumberOfPageFaults;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
