Question: implement and compare the three page replacement algorithms. - FIFO algorithm is provided for you as an example - CLOCK algorithm is very similar to
implement and compare the three page replacement algorithms.
- FIFO algorithm is provided for you as an example
- CLOCK algorithm is very similar to FIFO, but use a flag (used) to give a second chance to recently used pages
- Least Recently Used (LRU) algorithm requires a time stamp of pages used and picks the least recently used page to replace
- COUNT based algorithms uses requires a count of page access, least frequently used algorithm replace the page with the least count
// FIFO page Replacement algorithm
public static void pageReplAlgorithmFIFO(int vpage, Process prc)
{
int vPageReplaced; // Page to be replaced
int frame; // frame to receive new page
// Find page to be replaced
frame = prc.allocatedFrames[prc.framePtr]; // get next available frame
vPageReplaced = findvPage(prc.pageTable,frame); // find current page using it (i.e written to disk)
prc.pageTable[vPageReplaced].valid = false; // Old page is replaced.
prc.pageTable[vpage].frameNum = frame; // load page into the frame and update table
prc.pageTable[vpage].valid = true; // make the page valid
prc.framePtr = (prc.framePtr+1) % prc.allocatedFrames.length; // point to next frame in list
}
public static void pageReplAlgorithmCLOCK(int vpage, Process prc)
{
}
// LRU page Replacement algorithm
public static void pageReplAlgorithmLRU(int vpage, Process prc)
{
}
public static void pageReplAlgorithmCOUNT(int vpage, Process prc)
{
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
