Cache Replacement Algorithm - LRU
Cache Replacement LRU Algorithm - (Least Recently Used) Least Recently Used algorithm, the name itself represents its behavior. When we use this algorithm with the cache replacement policy, it will always remove the least used page from the cache and make space for the currently used page. Based on the above statement, we have to think about the implementation of the same. We need a data structure where we have to add all the recently used data from the tail and remove it from the head. For Example:- We can store a maximum of 3 pages in our cache. Suppose, we have the request of pages as given below. 3 , 2 , 1 , 0 , 2 , 3 , 7 , 4 , 7 Cache Frame 2 1 0 2 3 7 4 7 1 2 2 1 0 2 3 7 4 0 3 3 3 2 1 0 2 3 3 Page Status Cache Miss Cache Miss Cache Miss Cache Miss Cache Hit Cache Miss Cache Miss Cache Miss Cache Hit We will follow the steps to push the missing pages into the cache for the performance. If the page is found then remove it and again push it on the top. If the size o...