 Hello. Welcome to the session on LRU and optimal page replacement policies. Here LRU stands for least recently used. My name is Zayanan Patil, working as assistant professor in computer science and engineering department, Balchan Institute of Technology, Solaapur. At the end of this session, students will be able to explain LRU and optimal block replacement policies and solve the problems and calculate heat ratio for these methods. So before coming to LRU, in the previous video lecture, we were discussed the first in first out method. In that method, the block which was replaced first into the cache memory that was replaced to that was deleted to replace the new block in a main memory. But in this method, this policy selects for replacement of block that was least recently accessed by processor. That is, the blocks which are existed in the cache, among them the block which was least recently accessed by the processor that is deleted and replaced the new block. And in this policy, it is assumed that the block which was least recently accessed by the processor is not referenced in the future. Based on that assumption, this policy is implemented to increase the heat ratio. In this LRU implementation that each block in the cache memory is associated with an counter called as age register, which indicating the block which is least recently accessed by the processor. This is the example considering a paging system in which M1 has a capacity of 3 pages. That is M1 refers to the cache memory which sizes 3 pages and that executing application require the 5 distinct pages 1, 2, 3, 4 and 5. These pages are accessed in different stream. So, this is the stream required to execute the application and the answer is, so this is the status of the cache memory at different stages. Initially, the block 2 needs to be transferred from main memory to the cache memory. So, first 2 there is all blocks are empty. So, 2 will be placed here. Next 3 need to be accessed. So, 3 is not existed in the cache memory and the next block is free. So, 3 is placed here. Next 2 need to be accessed. 2 is already existed in the cache. So, no need to access the 2. So, cache heat occurs and 3 is marked with a star indicating that the 3 is least recently used. And 1 need to be accessed. So, 1 is not existed in the cache and there is a empty block. So, 1 is placed here. And next 5 need to be accessed. So, first we will check for the 5 is existed or not. No. And it need to be replaced anyone of these blocks because the cache memory is full here. So, that 5 is replaced with the least recently used block that is 3. So, now this is the status and the 2 is marked with a star indicating the least recently used block. And 2 needs to be accessed. So, 2 is already existed in the cache. So, the cache heat occurs and the 1 is marked as the least recently used. And 4 need to be accessed. The 4 is not existed in the cache. 4 is replaced with the 1. And 5 need to be accessed. So, 5 is already existed in the cache. So, no need to access the cache heat occurs and the least recently used is marked with a star. Next the block 3 needs to be accessed. So, 3 is not existed. So, it is replaced by 2 and 4 is marked as least recently used. And next 2 needs to be accessed. So, 2 is not existed. So, it is replaced by 4 and the 5 is marked as the least recently used. And 5 need to be accessed. So, 5 is already existed in the cache. So, cache heat occurs and next 2 need to be accessed. So, 2 is already existed in the cache. The cache heat occurs. So, after end of this process we will calculate the heat ratio that is total number of heat occurs that is 5 divided by total number of access. The heat ratio is 0.416. Next is the optimal replacement policy. So, this policy selects for the replacement of block which would not be used for the longest duration of time in the future. So, in this method it is assumed that. So, if we use the block which is if we delete the block which is not used for longest duration in the future then that will improve the heat ratio based upon that assumption this is implemented. Now, this is time to reflect. So, repeat the previous example for optimal replacement policy that is previous example is this one is the previous example. So, same example we are considering for the optimal replacement policy here. So, now we are familiar with how to perform that replacement policy, but in the optimal replacement policy based upon the point mentioned in the optimal replacement policy we are considering and performing the replacement process. Now, pause the video and perform the replacement method. Answer is so here. So, again for that example this is the blocks accessed in this stream. Initially that cache memory will be empty here we are not indicating any of these blocks with the star because we do not know which block needs to be deleted because if we need to replace any block we are observing the future list based upon the future list we are deleting. So, we are not indicating in advance any of the block to be deleted. So, first two need to be accessed. So, it is placed in the first block next three needs to be accessed it is placed in the second block next two. So, two is already existed. So, cache hit occurs here next one need to be accessed. So, it is empty block and one is not existed in the cache. So, one is replaced here and next the five need to be accessed five need to be accessed. So, we are observing two three one in the future list. So, that two three one two is here three is here. So, one is not present here. So, one is replaced with five and next the two need to be accessed two is already existed. So, that the cache hit occurs here. So, that two three five the cache hit occurs next four need to be replaced the four is observed in this cache memory four is not present in this memory. So, that four need to be accessed and it should be replaced. So, we are observing two three five in the future list which is not used in the longer duration that is deleted. So, two three five. So, five is required here three is required and two is required here. So, before two five and three is required. So, two is replaced and four that in place of two the block four is replaced and next five need to be accessed. So, that five is already existed in this cache memory. So, five is replaced no need to access the five and the cache hit occurs and next the block three needs to be replaced. So, that three is already existed in the cache memory the cache hit occurs next two need to be accessed. So, if the two need to access we need to replace any one of these block because the two is not existed in the cache memory. So, at this time so, we are observing four three five in the future list we will observe four three five. So, five is required and four and three is not required. So, while replacing two we are going to replace instead of any one of these blocks. So, that is four is not required. So, four the two is replaced with the first block that is four is not required and five is required. So, we cannot and instead of three and four anyone can use. So, first block four is used here and next five need to be accessed. So, five is already existed in the cache. So, that is why the five is that cache hit occurs and next two need to be accessed. So, two is already existed in the cache. So, that cache hit occurs. So, at the end of this process again we are calculating the heat ratio. So, that is again the heat ratio equals to that number of hits divided by the total number of access. So, the heat ratio equal to six divided by twelve here six is the number of hits. So, that is total number of hits is six and divided by the total number of access. The total number of access is twelve. So, six divided by twelve is 0.5. So, now if we compare the first in first out method and the least recent use method and the optimal replacement policies we are getting the more heat ratio. So, that is that heat ratio is increased in this method that is 0.5. In the previous method it was less than 0.5. So, according to this problem that we conclude that that optimal replacement policies will give that increased heat ratio compared to the previous two methods. So, these are the references I have used. Thank you.