[mmu/cache]-cache的一些基本概念介绍
快速鏈接:
.
👉👉👉 個人博客筆記導讀目錄(全部) 👈👈👈
文章目錄
- 1、Cache的一些基本概念
- (1)、cache的架構圖(L1、L2、L3 cache)
- (2)、cache的術語:set/way/line/index/tag/offset
- 2、Cache的一些屬性概念
- Cache分配策略(Cache allocation policy)
- (1)、讀分配(read allocation)
- (2)、寫分配(write allocation)
- Cache更新策略(Cache update policy)
- (3)、寫直通(write through)
- (4)、寫回(write back)
- properties of normal memory
- (5)、inner and outer
- PoC 和 PoU
- (6) Poc
- (6) PoU
- 3、cache的使用示例
- (1)、一個兩路組相連的cache
- (2)、一個32kb 四路組相連的cache
- (3)、Inclusive 和 exclusive cache
1、Cache的一些基本概念
(1)、cache的架構圖(L1、L2、L3 cache)
(2)、cache的術語:set/way/line/index/tag/offset
2、Cache的一些屬性概念
Cache分配策略(Cache allocation policy)
cache的分配策略是指我們什么情況下應該為數據分配cache line。cache分配策略分為讀和寫兩種情況。
(1)、讀分配(read allocation)
當CPU讀數據時,發生cache缺失,這種情況下都會分配一個cache line緩存從主存讀取的數據。默認情況下,cache都支持讀分配。
(2)、寫分配(write allocation)
當CPU寫數據發生cache缺失時,才會考慮寫分配策略。當我們不支持寫分配的情況下,寫指令只會更新主存數據,然后就結束了。當支持寫分配的時候,我們首先從主存中加載數據到cache line中(相當于先做個讀分配動作),然后會更新cache line中的數據。
Cache更新策略(Cache update policy)
cache更新策略是指當發生cache命中時,寫操作應該如何更新數據。cache更新策略分成兩種:寫直通和回寫。
(3)、寫直通(write through)
當CPU執行store指令并在cache命中時,我們更新cache中的數據并且更新主存中的數據。cache和主存的數據始終保持一致。
(4)、寫回(write back)
當CPU執行store指令并在cache命中時,我們只更新cache中的數據。并且每個cache line中會有一個bit位記錄數據是否被修改過,稱之為dirty bit(翻翻前面的圖片,cache line旁邊有一個D就是dirty bit)。我們會將dirty bit置位。主存中的數據只會在cache line被替換或者顯示的clean操作時更新。因此,主存中的數據可能是未修改的數據,而修改的數據躺在cache中。cache和主存的數據可能不一致。
properties of normal memory
(5)、inner and outer
PoC 和 PoU
(6) Poc
Poc是值對于不同的Master看到的一致性的內存; 例如對于cores,DSP,DMA他們一致性的內存就是main memory,所以main memory是PoC這個點
Point of Coherency (PoC). For a particular address, the PoC is the point at which all
observers, for example, cores, DSPs, or DMA engines, that can access memory, are
guaranteed to see the same copy of a memory location. Typically, this is the main external
system memory
(6) PoU
PoU是值指令和數據cache上一致的那個點,一般為L2 cache,如果系統中沒有L2 cache,那么PoU為main memory
Point of Unification (PoU). The PoU for a core is the point at which the instruction and
data caches and translation table walks of the core are guaranteed to see the same copy of
a memory location. For example, a unified level 2 cache would be the point of unification
in a system with Harvard level 1 caches and a TLB for caching translation table entries.
If no external cache is present, main memory would be the Point of Unification
3、cache的使用示例
(1)、一個兩路組相連的cache
(2)、一個32kb 四路組相連的cache
(3)、Inclusive 和 exclusive cache
wwww
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的[mmu/cache]-cache的一些基本概念介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [register]-ARMV8-aar
- 下一篇: [mmu/cache]-MMU的寄存器学