[mmu/cache]-cache的一些基本概念介绍
快速鏈接:
.
👉👉👉 個人博客筆記導(dǎo)讀目錄(全部) 👈👈👈
文章目錄
- 1、Cache的一些基本概念
- (1)、cache的架構(gòu)圖(L1、L2、L3 cache)
- (2)、cache的術(shù)語: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的架構(gòu)圖(L1、L2、L3 cache)
(2)、cache的術(shù)語:set/way/line/index/tag/offset
2、Cache的一些屬性概念
Cache分配策略(Cache allocation policy)
cache的分配策略是指我們什么情況下應(yīng)該為數(shù)據(jù)分配cache line。cache分配策略分為讀和寫兩種情況。
(1)、讀分配(read allocation)
當(dāng)CPU讀數(shù)據(jù)時,發(fā)生cache缺失,這種情況下都會分配一個cache line緩存從主存讀取的數(shù)據(jù)。默認(rèn)情況下,cache都支持讀分配。
(2)、寫分配(write allocation)
當(dāng)CPU寫數(shù)據(jù)發(fā)生cache缺失時,才會考慮寫分配策略。當(dāng)我們不支持寫分配的情況下,寫指令只會更新主存數(shù)據(jù),然后就結(jié)束了。當(dāng)支持寫分配的時候,我們首先從主存中加載數(shù)據(jù)到cache line中(相當(dāng)于先做個讀分配動作),然后會更新cache line中的數(shù)據(jù)。
Cache更新策略(Cache update policy)
cache更新策略是指當(dāng)發(fā)生cache命中時,寫操作應(yīng)該如何更新數(shù)據(jù)。cache更新策略分成兩種:寫直通和回寫。
(3)、寫直通(write through)
當(dāng)CPU執(zhí)行store指令并在cache命中時,我們更新cache中的數(shù)據(jù)并且更新主存中的數(shù)據(jù)。cache和主存的數(shù)據(jù)始終保持一致。
(4)、寫回(write back)
當(dāng)CPU執(zhí)行store指令并在cache命中時,我們只更新cache中的數(shù)據(jù)。并且每個cache line中會有一個bit位記錄數(shù)據(jù)是否被修改過,稱之為dirty bit(翻翻前面的圖片,cache line旁邊有一個D就是dirty bit)。我們會將dirty bit置位。主存中的數(shù)據(jù)只會在cache line被替換或者顯示的clean操作時更新。因此,主存中的數(shù)據(jù)可能是未修改的數(shù)據(jù),而修改的數(shù)據(jù)躺在cache中。cache和主存的數(shù)據(jù)可能不一致。
properties of normal memory
(5)、inner and outer
PoC 和 PoU
(6) Poc
Poc是值對于不同的Master看到的一致性的內(nèi)存; 例如對于cores,DSP,DMA他們一致性的內(nèi)存就是main memory,所以main memory是PoC這個點(diǎn)
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是值指令和數(shù)據(jù)cache上一致的那個點(diǎn),一般為L2 cache,如果系統(tǒng)中沒有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
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的[mmu/cache]-cache的一些基本概念介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [register]-ARMV8-aar
- 下一篇: [mmu/cache]-MMU的寄存器学