Module IV Memory Organization
LFU Page Replacement Algorithm It involves keeping track of the number of times a page is referenced in memory. Implementation: Assign a counter to every block that is loaded into the cache. Each time a reference is made the counter is incremented When the cache reaches capacity, system will search for the page with lowest counter and remove it from the cache
LFU Page Replacement Example Consider the reference string : 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 for a memory with three frames.
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1) 1 1(1)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1) 1 1(1) 2 2(1)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1) 1 1(1) 2 2(1) 0(2)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1) 1 1(1) 2 2(1) 0(2) 3 3(1)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1) 1 1(1) 2 2(1) 0(2) 3 3(1) 0(3)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Page Frame Hit -1 7 7(1) 0(1) 1 1(1) 2 2(1) 0(2) 3 3(1) 0(3) 4 4(1)
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0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0(4) 2(2) 1 1(1) 2(3) 0(5) 1(2) 7 7(1) 0(6) Hit Ratio = 9/20 No. of Page Faults = 11