所有人。Clock-Pro緩存替換
我已經閱讀了很多關於ClockPro緩存替換算法文章 - 改進的時鐘緩存替換的版本。爲了方便起見,我實現了Clock。現在我想用2隻手實現Java Clock-Pro(實際算法中冷熱手而不是3手)。我發現了一些說明:
The ClockPro Algorithm
On Start():
cold_block = first block
hot_block = first block
On Memory Lookup():
curr_block = NULL
If block is in cache:
Set clock bit
Return block to CPU
Else:
While curr_block == NULL:
If cold_block.clockbit == 0:
curr_block = cold_block
Else if cold_block.test == 1 :
Turn cold hand block hot
Unset the clockbit
Run Hot Hand Algorithm
Else:
cold_block.clockbit = 0
cold_block = cold_block.next
If curr_block is dirty : write
Find accessed block in memory
Return fetched block to the CPU
Replace curr_block with fetched one
Hot Hand Algorithm() :
curr_block = NULL
While curr_block == NULL:
If hot_block is cold :
hot_block.text = 0
Else if hot_block.clockbit == 0 :
Turn the block cold
Else :
hot_block.clockbit = 0
hot_block = hot_block.next
如果沒有人嘗試過,請回答一些問題:
什麼測試周期是什麼?它何時開始,我們可以使用什麼類型的。 它只是一點點,可以告訴我們,如果對象是在測試期間或不是,或者它是一個計數器? 在某些時刻,雙手是否可以指向一個街區?
如果有人能,請幫我算法的這種行爲在一個簡單的例子 由於模型..。