Page Replacement Algorithm - LRU

I am trying to teach myself the LRU algorithm using this youtube video . In the example below ( taken here ), why is 0 replaced with 3. Shouldn't 4 be replaced with 3, since 4 is the least used?

enter image description here

+4
source share
3 answers

LRU stands for Least Used. This is based on the use of the "temporary locality" of the link, that is, the idea that the same material will be used for a certain period of time.

In your case, the last three accesses to the current were 0 - 4 - 2. This means that from the pages in physical memory 0 was the least used, and therefore it is unloaded.

+5
source

Do not confuse the concept of LRU and Optimal Replacement Algo. In the above stack, 0 was used before using 4, so when you need to replace it, 0 is used recently compared to 4 and 2, which are also on the stack.

0
source

Least Recent Used means that if we have 3 memories and we have pages 4 9 7 5. Thus, 4, 9 and 7 will be added to the frames. Now we want to replace page 5. Thus, we will check in memory which page is the least recently used. In our case, page number 4 is LRU, so we will replace 4 with 5.

In your case, 2 has been using Ist recently, 4 is the second most recent, and 0 is the last use , so we will replace 0 with 3.

0
source

Source: https://habr.com/ru/post/1413345/


All Articles