Question: In this assignment, you will implement a page table and analyze different page replacement algorithms, assuming a single running process and a fixed - size
In this assignment, you will implement a page table and analyze different page replacement algorithms, assuming a single running process and a fixedsize physical memory.
pagetable.h and cpp: It defines a "PageTable" class, which is just an array of Page Entries. Each page entry has a frame number, valid bit and dirty bit not used in this assignment Remember the virtual page number is the index to the array. You need to complete the implementation of the PageTable in the pagetable.cpp file.
replacement.h and cpp: It defines a "Replacement" class, the base class of the classes that implement specific replacement algorithms. You will need to add additional member variables to keep track of the statistics, such as numberofpagefaults and numberofpagereplacements, etc. Then complete the replacement.cpp file, especially the accesspage function. The accesspage function simulates the access by a single page number. If the page is found to be in memory, ie the corresponding page entry is valid, it calls the touchpage function; if the page isn't in memory but there are still free frames available, it would call the loadpage function; if the page isn't in memory and there isn't any free frame, it then calls the replacepage function. The touchpage loadpage and replacepage are virtual functions that can be overridden for different replacement algorithms in the subclasses.
fiforeplacementh and cpp: FIFOReplacement is a subclass of the Replacement, and implements the FIFO page replacement algorithm. You will need to complete its constructor and destructor, and override the functions loadpage and replacepage
liforeplacementh and cpp: LIFOReplacement is a subclass of the Replacement, and implements the LIFOLast in first out page replacement algorithm. It replaces a page that was last loaded into the memory. It isn't a good replacement algorithm and Let's see how bad it is You will need to complete its constructor and destructor, and override the functions loadpage and replacepage
lrureplacementh and cpp: LRUReplacement is a subclass of the Replacement, and implements the LRU page replacement algorithm. You will need to complete its constructor and destructor, and override the functions touchpage loadpage and replacepage
main.cpp: The driver program tests the implementation of the page table and replacement algorithms. Test using a "smallrefstxt file has been written. You need to complete test for the three replacement algorithms using a "largerefstxt file. See below for more info about the tests. The results of tests should match example outputs in the "exampleouttxt
Your program should support at least three pagereplacement policies: FIFO, LIFO, and LRU. Assume that when it starts, the physical memory is empty, ie all page table entries are invalid. As they are brought in the program should ensure that the total number of pages in memory should never exceed the physical memory size.
Your program should keep track of pages in the memory and free frames. Therefore, you need to maintain a pagetable data structure, which can be easily implemented as an array of page entries. The size of the array equals the number of pages in the logical memory. The page entry data structure may contain the mapped frame number of the page, valid bit, and dirty bit, etc. For each memory reference, calculate its page number and check whether this page is in the main memory by looking up the page table. If this page is not in the main memory, a page fault is generated, the missing page is loaded into the main memory, and the page table is updated. However, if the main memory is full, ie no more free frames, a victim page must be selected and evicted according to a page replacement algorithm. Your program compares different page replacement algorithms in terms of the total number of page faults. Notice you will need to keep track of additional information in the implementations, such as the last page access time for the LRU least recently used algorithm.
The program should accept the page size and physical memory size # of address bits as commandline arguments. The page size must be a power of between and bytes inclusively. The physical memory size is also a power of between and MB Using the provided Makefile, you just type "make" to build the executable "prog Then run "prog with commandline arguments, for example
prog
simulates a system with page size bytes and MB physical memory. You should thoroughly test your program with multiple configurations of different page sizes bytes and physical memory sizes eg MB MB MB MB and then present and analyze the data results in the report.
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
