java.lang.Object | +----PageFault
public PageFault()
public static void replacePage(Vector mem, int virtPageNum, int replacePageNum, ControlPanel controlPanel)
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.