CSC 442 Homework 4

Write a program that simulates a virtual memory page replacement algorithm. The program should read from a file: a page reference string, the size of the physical memory (in pages) and the algorithm to be used (MRU, LRU, OPTIMAL or FIFO). The program should then display the content of the physical memory and the number of page faults after each page reference in the given string.
Please respect the order specified: the program should read a page reference string, the size of the physical memory (in pages) and the algorithms to be used  IN THIS ORDER!!!

A sample of an input file is given below:

1 2 3 4 5 2 3 1 4 5 2 3 5 4 3 2 2 1 3 4 5

3

MRU LRU OPTIMAL FIFO

As you can see, the requests are separated by spaces, the number of frames avaiable is on a different line and the algorithms are also separated by spaces. The algorithms stand for:

MRU - Most Recently Used

LRU - Least Recently Used

OPTIMAL - The optimal algorithm

FIFO - First In, First Out

Submit:

  1. A print-out of your program.
  2. A written description of the program and its behavior. The description should be such that a reader not familiar with the topic be able to understand the algorithm.
  3. The source code of the program and a sample input file. The source code should be contained in a folder (directory) called "homework4" in your home directory. The permissions of this folder and all the files included should be such that I can open the files, compile them and run the program.