Class PageFault

java.lang.Object
   |
   +----PageFault

public class PageFault
extends Object

Constructor Index

 o PageFault()

Method Index

 o replacePage(Vector, int, int, ControlPanel)
The page replacement algorithm for the memory management sumulator.

Constructors

 o PageFault
 public PageFault()

Methods

 o replacePage
 public static void replacePage(Vector mem,
                                int virtPageNum,
                                int replacePageNum,
                                ControlPanel controlPanel)
The page replacement algorithm for the memory management sumulator. This method gets called whenever a page needs to be replaced.

The page replacement algorithm included with the simulator is FIFO (first-in first-out). A while or for loop should be used to search through the current memory contents for a canidate replacement page. In the case of FIFO the while loop is used to find the proper page while making sure that virtPageNum is not exceeded.

   Page page = ( Page ) mem.elementAt( oldestPage )
 
This line brings the contents of the Page at oldestPage (a specified integer) from the mem vector into the page object. Next recall the contents of the target page, replacePageNum. Set the physical memory address of the page to be added equal to the page to be removed.
   controlPanel.removePhysicalPage( oldestPage )
 
Once a page is removed from memory it must also be reflected graphically. This line does so by removing the physical page at the oldestPage value. The page which will be added into memory must also be displayed through the addPhysicalPage function call. One must also remember to reset the values of the page which has just been removed from memory.

Parameters:
mem - is the vector which contains the contents of the pages in memory being simulated. mem should be searched to find the proper page to remove, and modified to reflect any changes.
virtPageNum - is the number of virtual pages in the simulator (set in Kernel.java).
replacePageNum - is the requested page which caused the page fault.
controlPanel - represents the graphical element of the simulator, and allows one to modify the current display.