Search code examples
memory-managementpagingfifolrupage-replacement

Are the LRU and FIFO page replacements done correctly here?


I am just only learning about paging and was wondering if what I did for my page replacements was correct as the tutorials I found online seem a bit all over the place. I am mostly seeking clarification on whether I've done anything wrong and would like an explanation instead of a direct link to something elsewhere I have to further interpret things which don't really help.

I've done one with 3 frames of memory for the sequence, 0, 3, 1, 2, 3, 2, 0, 1, 0, 1, 3, 0, 2, 3, 1

Screenshot of my working

Y = there was a fault and N = No fault.

UPDATE:Tried fixing my FIFO, new working for FIFO


Solution

  • sequence of steps for fifo operation

    While doing fifo, in each step, we copy the previous cache state. Note that the cache slots are from left to right by oldest to youngest. Depending on hit or miss, we do one of the two things:

    If hit then do nothing.

    If miss then, delete the leftmost cache entry. Append new entry to the right.

    While doing lru, everything remains same except that when hit, we move the hit item to the rightmost slot. This means the item hit becomes the youngest among its peers.