从程序员的角度看cache(五)
参考:《超标量处理器设计》p_94
执行访问存储器指令时,涉及如下四种部件(暂不考虑硬盘)
- D-TLB
- Page Table
- D-cache
- Page
每种部件都可能命中/缺失,故有16中组合,但:
- 如果D-TLB命中,则Page Table必然命中;
- 如果D-Cache命中,则Page必然命中;
- 如果Page Table命中,则Page必然命中;
剔除不可能组合,执行load/store指令时可能引起的情况如下(注意given-xx):
| Scenario | TLB | Page Table | D-Cache | Page | Comment |
| D-Cache hit | given-hit | Sure hit | hit | Sure hit | Needn't check memeory |
| D-Cache hit | given-miss | Sure hit | hit | Sure hit | Fill TLB, access TLB again |
| D-Cache miss | given-hit | Sure hit | miss | Sure hit | Fill D-cache |
| D-Cache miss | given-miss | given hit | miss | Sure hit | Fill TLB, Fill D-Cache |
| Page Fault | sure miss | sure miss | sure miss | sure miss | do page fault |
浙公网安备 33010602011771号