471 words
2 minutes
Page views--Visits--
computer architecture (9) Cacheの基本原則
alt text
  • Cache的基本原理#

    • Cache的工作原理
    • 局部性原理
    • 性能分析
    • 有待解决的问题

Cache的工作原理#

alt text alt text

局部性原理#

程序的局部性原理解释。 alt text

性能分析#

对于CPU想要的数据,如果直接能在Cache中找到,就被称为Cache命中,与之对应的指标叫命中率H,相对的也有缺失(未命中率)M。

因此可以得到Cache-主存系统的平均访问时间为:

t=Htc+(1−H)(tc+tm)t = Ht_c + (1 - H)(t_c + t_m)

(这是CPU先访问Cache,若未命中再访问主存时的公式。)

或 t=Htc+(1−H)tmt = Ht_c + (1 - H)t_m

(这是CPU同时访问Cache和主存的公式。) alt text

alt text

有待解决的问题#

主存与Cache之间以“块”为单位进行数据交换。

主存地址可拆分为(主存块号,块内地址)的形式。

对于4MB的主存,会发现若按1KB分块,块内地址刚好有10位,被分为4096块,刚好有12位来表示块号。 alt text

有待解决的问题:

  1. 如何区分Cache与主存的数据块对应关系 — Cache和主存的映射方式

  2. Cache很小,主存很大。如果Cache满了怎么办? — 替换算法

  3. CPU修改了Cache中的数据副本,如何确保主存中数据母本的一致性? — Cache写策略


知识回顾#


alt text
computer architecture (9) Cacheの基本原則
https://blog.apoyu.com/posts/0015/
Author
Apoyu
Published at
2025-09-19

Share Article

Generate a share poster or copy the link to share this article.

Continue reading

Related reading

Based on shared tags and categories

Take another route

A consistent pick from other articles

Comments

Loading comments...

Last updated on , 402 days ago

Some content may be outdated