jasperzhong / cs-notes

CS认知体系
6 stars 0 forks source link

Cache coherence #16

Closed jasperzhong closed 3 years ago

jasperzhong commented 3 years ago

https://en.wikipedia.org/wiki/Cache_coherence

write-through vs write-back

jasperzhong commented 3 years ago

当系统写数据到cache的时候,之后肯定要把这个数据写入到backing store.

write policy有两个基本方式:

所以write-back策略下,一次read miss会导致两次memory accesses: 一个是把要替换的data写入到backing store, 一个是retrieve需要的data.

jasperzhong commented 3 years ago

wikipedia上的这两个图总结了上面流程:

A write-through cache with no-write allocation: image

A write-back cache with write allocation: image

顺带提一句,这些都是用硬件完成的.

jasperzhong commented 3 years ago

脏数据(dirty data)指的是缓存上还没有写入到backing store的数据.