gem5中LRU算法解释

参考:http://thread.gmane.org/gmane.comp.emulators.m5.users/8524/focus=8552

关于gem5中LRU算法的解释,主要是accessBlock和findVictim两个函数,具体示例如下:

This example will show that

sets[i]=| head |  ....  | tail |

init
(b1,0) (b2,0) (b3,0) (b4,0)

b1 is accessed
(b1,1) (b2,0) (b3,0) (b4,0)

b3 is accessed
(b3,1) (b1,1) (b2,0) (b4,0)

b1 is accessed
(b1,2) (b3,1) (b2,0) (b4,0)

b4 is accessed
(b4,1) (b1,2) (b3,1) (b2,0)

b2 is accessed
(b2,1) (b4,1) (b1,2) (b3,1)

Now want to evict? Head shows the MRU and tail shows the LRU. The line
BlkType *blk = sets[set].blks(assoc-1];

always point to tail. So (b3,1) is found as victim.

你可能感兴趣的:(gem5中LRU算法解释)