For this assignment you are to implement a program that accepts a choice of a replacement algorithm (FIFO, OPTIMAL, or LRU), a number of memory frames, and a reference string. For development purposes you can use the following data:
F,3,0,1,2,3,2,3,0,4,5,2,3,1,4,3,2,6,3,2,1,2
O,3,0,1,2,3,2,3,0,4,5,2,3,1,4,3,2,6,3,2,1,2
L,3,0,1,2,3,2,3,0,4,5,2,3,1,4,3,2,6,3,2,1,2
(NOTE: First Letter = the replacement algorithm, i.e. F, O, L
First number after the letter is the number of memory frames, followed by the reference string, e.g. in F,3,0,1,2, .... F= FIFO, No. of memory frames = 3, Ref. string = 0,1,2,...)
The input file will be given to students through the data file (Lab2.dat).
Your program should calculate the number of page faults and display an output similar to slides in the chapter 9 (virtual memory) depending on the algorithm selected. (When no page fault occurs you may show the column as blank or you may simply show the pages that are there without any change.) You will assume that the reference string is generated by one process and consider local replacement only. This is an example of desired output using FIFO and 3 frames.
for FIFO
0: <0, , >
1: <1,0, >
2: <2,1,0>
3: <3,2,1>
2: <3,2,1>
3: <3,2,1>
0: <0,3,2>
4: <4,0,3>
5: <5,4,0>
2: <2,5,4>
3: <3,2,5>
...
The number of page fault using FIFO = xx