Write a C++ program that simulates the operation of 3 page replacement algorithms used in a virtual memory management system:
You will simulate each algorithm on the input data sets and report the performance of each. A description of each of these algorithms appears in Chapter 10 of our text.
Your program must take two arguments:
prog02 <data_file> <num_frames>
These arguments are:
Program arguments can either be specified at the command line, or preferably input by the user after the program starts running.
Each data file will contain one reference string. The reference string represents an ordered list of page references. So, for example, the string:
4 5 4 6
means that page #4 is referenced, then page #5, then page #4 again, then finally page #6.
First, echo the input for this simulation, including the data file name, reference string, and frame number.
Then, for each data set, you should output the following for each of the three algorithms:
Algorithm: <FIFO,LRU,Optimal> |
Page faults: <num> |
Page Table: |
Page: 1 Frame: <num> |
Page: 2 Frame: <num> |
... |
Page: n Frame: <num> |
Each field means:
Some simulation pointers:
You will be expected to run your program on a set of data files of this format. These files will be located in the CSC 420 k: drive common folder:
k:/02SP/CSC420/Common Area/prog02/data/
Program #2 is worth 50 points, or 5% of your class grade.
Please place your source code, executable, and output data in a folder called prog02 on your k: drive.
Your design of Program #2 is due Thurs May 9. This is just like program #1, so please hand-in:
Also, please print your headers and pseudo-code for grading/review.
Program #2 is due Thursday May 16.
Deliverables include:
Grading will be similar to Program #1:
I am less interested in:
The first data set is page335.txt and can be found on the k: drive. It's also here:
I'll publish the other data sets next week.
My implementaion probably includes the following classes:
My solution will probably use the list and queue data types from the STL. For STL examples, try the "Help" menu in Visual C++ and search for STL. Also, you can spot my usage of STL components queue, list and iterator in my implementation of program #1 on the k: drive.
I would tackle the FIFO algorithm first, then LRU, then Optimal. Optimal is probably the hardest because you have to use the whole reference string to determine which page is replaced.
OK, please run the following simulations:
The data set files are available in the Common Area/prog02/data folder.
I would like to add one more requirement to your output file for each simulation run. For each page reference write an abbreviated version of the page table, showing the (page, frame) for each page currently in memory. For example, it may look something like this:
Page table (page,frame): (0,1) (1,2) (2,3) (7,0)
I request that you do this, 1) to force you to create a way to debug and verify your results, and 2) make it easier for me to understand incorrect results.