📄 第四节.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>存储器层次结构的公共框架(1) </title>
<meta name="Microsoft Theme" content="arcs 011">
</head>
<body background="../images/arctile.jpg" bgcolor="#FFFFFF" text="#000000" link="#3399FF" vlink="#666666" alink="#FF9900">
<p align="center"><font size="6" color="#000000">第四节 存储器层次结构的公共框架</font>
</p>
<p align="center"><font color="#000000" size="6">存储器层次结构的公共框架(1)</font>
</p>
<p align="right"><font color="#000000"><a href="Index.htm"><img border="0" src="IMAGES/BACK.GIF" align="left" width="60" height="45"></a><font size="6"> </font>
<a href="3。3.htm"><img border="0" src="IMAGES/PREV.GIF" width="60" height="45"></a>
<a href="4.2.htm"><img border="0" src="IMAGES/FORW.GIF" width="60" height="45"></a></font>
</p>
<p><font size="6" color="#000000"> </font>
</p>
<p><font color="#000000"><font size="6"> </font><font size="5"> </font><font size="4"> </font></font>
</p>
<p><font color="#000000" size="4"> 下面讨论存储系统的共性问题.</font>
</p>
<table border="1" width="99%" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
<tr>
<td width="21%"><font color="#000000" size="4"> Feature</font></td>
<td width="25%"><font color="#000000" size="4">Typical values for catches</font></td>
<td width="29%"><font color="#000000" size="4">Typical values for paged
memory</font></td>
<td width="25%"><font color="#000000" size="4">typical values for a TLB</font></td>
</tr>
<tr>
<td width="21%"><font color="#000000" size="4">Total size in blocks</font></td>
<td width="25%"><font color="#000000" size="4">250-10,000</font></td>
<td width="29%"><font color="#000000" size="4">2,000-250,000</font></td>
<td width="25%"><font color="#000000" size="4">32-1024</font></td>
</tr>
<tr>
<td width="21%"><font color="#000000" size="4">Total size in bytes</font></td>
<td width="25%"><font color="#000000" size="4">4KB-4MB</font></td>
<td width="29%"><font color="#000000" size="4">8MB-1GB</font></td>
<td width="25%"><font color="#000000" size="4">128-8000</font></td>
</tr>
<tr>
<td width="21%"><font color="#000000" size="4">Block size in bytes</font></td>
<td width="25%"><font color="#000000" size="4">4-256</font></td>
<td width="29%"><font color="#000000" size="4">4KB-16KB</font></td>
<td width="25%"><font color="#000000" size="4">4-16</font></td>
</tr>
<tr>
<td width="21%"><font color="#000000" size="4">Miss penalty in clocks</font></td>
<td width="25%"><font color="#000000" size="4">10-100</font></td>
<td width="29%"><font color="#000000" size="4">100,000-1,000,000</font></td>
<td width="25%"><font color="#000000" size="4">10-50</font></td>
</tr>
<tr>
<td width="21%"><font color="#000000" size="4">Miss rates</font></td>
<td width="25%"><font color="#000000" size="4">0.1%-20%</font></td>
<td width="29%"><font color="#000000" size="4">0.00001%-0.0001%</font></td>
<td width="25%"><font color="#000000" size="4">0.01%-1%</font></td>
</tr>
</table>
<p><font color="#000000" size="4"> 图7.21充量的说明了存储系统的特性.</font>
</p>
<p><font size="4" color="#000000">1.地址映射(变换)的方法</font>
</p>
<p><font color="#000000" size="4"> 1) 直接映射DIRECT MAPPING </font>
</p>
<p><font color="#000000" size="4"> 在CACHE中看到,设J是高层存储器的字块号,I是低层存储器的块号,M是高层存储器的块数,则J=I MOD M<br>
<br>
例如(图7.22):替换存储块号为12的三种方法。在直接映射法中,高层存储器为8块,12 mod 8=4。在二路组相联法中,一共有4组,12
mod 4=0,所以可以替换该组中任意个元素。在全相联法中,数据可以在任一位置出</font>
</p>
<p><font color="#000000" size="4"> 现. <img border="0" src="IMAGES/第四1.gif" width="653" height="281">
</font>
</p>
<p><font color="#000000" size="4"> </font>
</p>
<p><font color="#000000" size="4"> </font>
</p>
<p><font color="#000000" size="4">
直接映的优点是实现简单,只需利用主存地址某些字段直接判断,即可确定所虚字块是否在Cache中。其缺点是不够灵活,主存中的字块只能对应唯一的Cache字块,因此 Cache中别的许多地址也不能占用,这使得Cache存储空间得不到充分的利用,并降低了利用率.</font>
</p>
<p><font color="#000000" size="4"> 2) 全相联映象</font>
</p>
<p><font color="#000000" size="4"> 在虚存系统中可以看到,一个逻辑地址可以放到任何一个物理页中。<br>
<br>
主存地址</font>
</p>
<div align="center">
<center>
<table border="1" width="73%" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
<tr>
<td width="50%"><font color="#000000" size="4">
实际页号数</font></td>
<td width="50%"><font color="#000000" size="4">
页面地址</font></td>
</tr>
</table>
</center>
</div>
<p><font color="#000000" size="4"> </font>
</p>
<p><font color="#000000" size="4"> 3) 组相联映象</font>
</p>
<p><font color="#000000" size="4"> 主存地址</font>
</p>
<div align="center">
<center>
<table border="1" width="74%" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
<tr>
<td width="13%"><font color="#000000" size="4"> Tag</font></td>
<td width="25%"><font color="#000000" size="4"> cache组地址</font></td>
<td width="29%"><font color="#000000" size="4">
组内快号</font></td>
<td width="33%"><font color="#000000" size="4">
块内地址</font></td>
</tr>
</table>
</center>
</div>
<p><font color="#000000" size="4"><br>
介于上述两者之间的地址转换方式,把CACHE分为N组,每组有N页,在组内实行全相联,在组外实行直接映射.</font>
</p>
<p><font color="#000000" size="4"> 讨论:全相联是组相联的一个特例,只有一个组的组相联。组相联,组内分块可以提高命中率,但是从4字块到8字块的命中率变化不大.</font>
</p>
<p><font color="#000000" size="4"> 实例比较:</font>
</p>
<p><font color="#000000" size="4"> 例1(图7.23):cache一共有八块,直接映射、二路组相联、四路组相联和</font>
</p>
<p><font color="#000000" size="4"> 全相联的结构如下图所示。</font>
</p>
<p><font color="#000000" size="4"> <img border="0" src="IMAGES/第四2.gif" width="629" height="510">
</font>
</p>
<p><font color="#000000" size="4"> 例2:有三个cache,每个cache分为四块,每一块一个字,给定存储器访问的地址是0,8,0,6,8,现在分别用前面三种方法测试一下命中率.
其中组相联每组二块。</font>
</p>
<p><font color="#000000" size="4"> 解 : a.直接映象法 </font>
</p>
<p><font color="#000000" size="4">
每一块到cache的地址映象: 0 MOD 4 =0 6 MOD 4 =2
</font>
</p>
<p><font color="#000000" size="4"> 4 MOD 4 =0 8 MOD 4 =0</font>
</p>
<p><font color="#000000" size="4">
所以直接映象0,8,0,6,8,这五次都失败.</font>
</p>
<div align="center">
<center>
<table border="1" width="74%" height="67" bordercolordark="#CC9966" bordercolorlight="#FFCC66">
<tr>
<td width="9%" height="38" rowspan="2"><font color="#000000" size="4">Address
of memory block accessed</font></td>
<td width="6%" height="38" rowspan="2"><font color="#000000" size="4">Hit
or miss</font></td>
<td width="50%" height="45" colspan="4"><font color="#000000" size="4">contents
of cache blocks after reference</font></td>
</tr>
<tr>
<td width="12%" height="29"><font color="#000000" size="4">
0</font></td>
<td width="13%" height="29"><font color="#000000" size="4">
1</font></td>
<td width="12%" height="29"><font color="#000000" size="4">
2</font></td>
<td width="13%" height="29"><font color="#000000" size="4">
3</font></td>
</tr>
<tr>
<td width="9%" height="22"><font color="#000000" size="4">
0</font></td>
<td width="6%" height="22"><font color="#000000" size="4">Miss</font></td>
<td width="12%" height="1"><font color="#000000" size="4">Memory[0]</font></td>
<td width="13%" height="1"></td>
<td width="12%" height="1"></td>
<td width="13%" height="1"></td>
</tr>
<tr>
<td width="9%" height="16"><font color="#000000" size="4">
8</font></td>
<td width="6%" height="16"><font color="#000000" size="4">Miss</font></td>
<td width="12%" height="16"><font color="#000000" size="4">Memory[8]</font></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -