我们经常听到 Cache Flush,它的含义是:Clean 并且 Invalidate Cache。
那什么是 Clean Cache 操作,什么是 Invalidate Cache 操作?
-
Invalidate Cache
- 重置 Cache 或者 Cache line 的有效位。如果 Cache 中还存在“脏”数据,那么直接进行 Invalidate 操作将导致错误。例如,一个写回策略采用 Write-back 的 Cache,如果直接进行 Invalidate 操作,很多有效数据将失。
-
Clean Cache
- 将“脏”的 Cache-line 的数据写回显存,并重置 Cache-line 的有效位。该操作可以保证 Cache 和显存数据的一致性。该操作常用于采用 Write-back 写回策略的 Cache。
网友评论