Skip to content

Commit

Permalink
更新cache映射方式
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcaffebabe committed Feb 8, 2020
1 parent 29ad244 commit 945c83c
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 3 deletions.
Binary file added assets/批注 2020-02-08 164919.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/批注 2020-02-08 165705.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/批注 2020-02-08 185829.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 55 additions & 3 deletions 计算机系统/程序结构和执行/存储器层次结构.md
Expand Up @@ -245,14 +245,66 @@ DRAM与SRAM不同的是,需要间隔一段时间执行刷新操作

![批注 2020-02-08 162726](/assets/批注%202020-02-08%20162726.png)

## 相联存储器
### 相联存储器

- 如何快速地查找
- 如何快速地判断数据是否存在

## 通用的高速缓存存储器组织结构
### Cache地址映射与变换方法

## 直接映射高速缓存
- 主存数据如何迁至Cache才能实现快速查找

#### 全相联映射

![批注 2020-02-08 164919](/assets/批注%202020-02-08%20164919.png)

- 主存分块,Cache行 (Line),两者大小相同
- 设每块4个字,主存大小为1024个字,则第61个字的主存地址为:
- 00001111 01 (块号 块内地址)
- 主存分块后地址就从一维变成二维
- 映射算法:主存的数据块可映射到Cache任意行,同时将该数据块地址对应行的标记存储体中保存

**特点**

- Cache利用率高
- 块冲突率低
- 淘汰算法复杂

所以应用在小容量cache

#### 直接映射

![批注 2020-02-08 165705](/assets/批注%202020-02-08%20165705.png)

- 主存分块,Cache行 (Line),两者大小相同
- 主存分块后还将以Cache行数为标准进行分区
- 设每块4个字,主存大小为1024个字,Cache分为4行,第61个字的主存地址为
- 000011 11 01 (区号,区内块号,块内地址)
- 主存地址从一维变成三维
- 映射算法:Cache共n行,主存第j块号映射到Cache 的行号为 i=j mod n
- 即主存的数据块映射到Cache特定行

**特点**

- Cache利用率低
- 块冲突率高
- 淘汰算法简单

应用在大容量cache

#### 组相联映射

![批注 2020-02-08 185829](/assets/批注%202020-02-08%20185829.png)

- 主存分块,Cache行 (Line),两者大小相同;
- Cache分组(每组中包k行),本例假定K=4
- 主存分块后还将以Cache组数为标准进行分组;
- 设每块4个字,主存大小为1024个字,Cache分为4行,第61个字的主存地址为:
- 0000111 1 01 (组号,组内块号,块内地址)
- 主存地址从一维变成三维;
- 映射算法:
- Cache共n组,主存第j块号映射到Cache 的组号为:i=j mod n
- 即主存的数据块映射到Cache特定组的任意行

## 缓存写

Expand Down

0 comments on commit 945c83c

Please sign in to comment.