I have to create a class that illustrates the implementation of FIFO page replacement algorithms on string of value passed in and then record the page faults incurred.
The number of frames that is used is a fixed at 7 and the size of the string will be 20 values.
I was thinking that the best way to create this would be to
Put the string values in an array.
Have a for loop reading values from the array and using a queue to show the FIFO.
Then finally using an if statement to judge if the inserted value is the same as replaced and thus counting up the faults.
Can you suggest if I am going about this the correct way or if there is a more efficient way of carrying this out.
What do you mean by page faults, frames, and value size?
Is the value size the amount of strings passed in?
By frames i mean that there will be the number of inserts done before the first one has to be removed.
eg. say theres 3 frames
1 2 3
4 2 3
The value size is the amount of numbers i will be using in the string.
eg. there are 6
And a page fault is basically where the number inserted is not the same as the value being replaced
I hope that explains things a bit better
This is evidently an algorithm that would be used in an OS to obtain a page that is needed in memory, but not present. it is a dynamic process, and of course works because most memory access is to places close to the current address.
I had to something like this over a dozen years ago, but I was using C/C++ and don't remember a lot except that I was using a stack. Doesn't help you, but it would seem that you could use sets, and see if the current page is in the set.