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: