I'm doing some theoretical examples with different page replacement algorithms, in order to get a better understanding for when I actually write the code. I'm kind of confused about this example.
Given below is a physical memory with 4 tiles (4 sections?). The following pages are visited one after the other:
R = 1, 2, 3, 2, 4, 5, 3, 6, 1, 4, 2, 3, 1, 4Run the FIFO page replacement algorithm on R with 4 tiles.
I know that when a page needs to be swapped in, the operating system swaps out the page which has been in the memory for the longest period of time. In practice I'll have:
Time 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Page 1 2 3 2 4 5 3 6 1 4 2 3 1 4
Tile 1 1 1 1 1 1 5 5
Tile 2 2 2 2 2 2 2
Tile 3 3 3 3 3 3
Tile 4 4 4 4
I'm not sure what happens at time = 8. I know that it won't replace page 5 and 4, but I'm not sure between 3 and 2. Since at time = 4 we have a 2, does it mean that page 3 will be replaced? Or is it that, since at time = 4, we already had 2 in the memory, therefore at time = 8 we replace 2?