CSC 420 Programming Assignment #2


Description

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.

Input

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.

Output

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:

Simulation

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/

Deliverables and Schedule

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.

Design Phase [10 points]

Your design of Program #2 is due Thurs May 9. This is just like program #1, so please hand-in:

  1. C++ header files defining the public interface for each "important" class, including comments describing each class and public method.
  2. Pseudo-code describing your program's execution flow; this is probably your main() function.
  3. Your main.cpp file should include all the headers that you have defined, and it should successfully compile.

Also,  please print your headers and pseudo-code for grading/review.

Program Finale [40 points]

Program #2 is due Thursday May 16.

Deliverables include:

  1. Source code - commented and beautiful, of course
  2. Executable  - I must be able to run your program and get your results
  3. Output files - for each data set
  4. A README file - for organization notes or things I need to know when reviewing your program

Grading will be similar to Program #1:

I am less interested in:

Notes

The first data set is page335.txt and can be found on the k: drive. It's also here:

page335.txt

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.

May 9, 2002

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.