📄 2。3.htm
字号:
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name="Microsoft Theme" content="arcs 011">
<meta http-equiv=Content-Type content="text/html; charset=GB2312">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<link rel=File-List href="./2。3.files/filelist.xml">
<link rel=Edit-Time-Data href="./2。3.files/editdata.mso">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<title>高速缓存(3)</title>
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>Dracula</o:Author>
<o:Template>Normal</o:Template>
<o:LastAuthor>Dracula</o:LastAuthor>
<o:Revision>2</o:Revision>
<o:TotalTime>0</o:TotalTime>
<o:Created>2002-06-24T03:51:00Z</o:Created>
<o:LastSaved>2002-06-24T03:51:00Z</o:LastSaved>
<o:Pages>4</o:Pages>
<o:Words>338</o:Words>
<o:Characters>1927</o:Characters>
<o:Company>Tomb</o:Company>
<o:Lines>16</o:Lines>
<o:Paragraphs>3</o:Paragraphs>
<o:CharactersWithSpaces>2366</o:CharactersWithSpaces>
<o:Version>9.2812</o:Version>
</o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
<w:Compatibility>
<w:UseFELayout/>
</w:Compatibility>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:宋体;
mso-bidi-font-family:"Times New Roman";
color:black;}
a:link, span.MsoHyperlink
{color:#3399FF;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:#666666;
text-decoration:underline;
text-underline:single;}
p
{font-size:12.0pt;
font-family:宋体;
mso-bidi-font-family:"Times New Roman";
color:black;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1028"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1"/>
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white background="..\images\arctile.jpg" lang=ZH-CN link="#3399ff"
vlink="#666666" style='tab-interval:21.0pt' alink="#FF9900">
<div class=Section1>
<p align=center style='text-align:center'><span style='font-size:24.0pt'>高速缓存(<span
lang=EN-US>3)</span></span> </p>
<p align=right style='text-align:right'><span lang=EN-US><a href="Index.htm"></a></span><!--[if gte vml 1]><v:shapetype
id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_s1026" type="#_x0000_t75" alt=""
href="Index.htm" style='position:absolute;left:0;text-align:left;
margin-left:0;margin-top:0;width:45pt;height:33.75pt;z-index:1;
mso-wrap-distance-left:0;mso-wrap-distance-top:0;mso-wrap-distance-right:0;
mso-wrap-distance-bottom:0;mso-position-horizontal:left;
mso-position-horizontal-relative:text;mso-position-vertical-relative:line'
o:allowoverlap="f" o:button="t">
<v:imagedata src="IMAGES\BACK.GIF"/>
<w:wrap type="square"/>
</v:shape><![endif]--><![if !vml]><a href="Index.htm"><img border=0 width=60
height=45 src="IMAGES\BACK.GIF" align=left v:shapes="_x0000_s1026"></a><![endif]><a
href="Index.htm"></a><span lang=EN-US>
<a href="2.2.htm"><span style='text-decoration:none;text-underline:none'><img
border=0 width=60 height=45 id="_x0000_i1025" src="IMAGES\PREV.GIF"></span></a>
<a href="2。4.htm"><span
style='text-decoration:none;text-underline:none'><img border=0 width=60
height=45 id="_x0000_i1026" src="IMAGES\FORW.GIF"></span></a></span></p>
<p><span lang=EN-US style='font-size:13.5pt'>4.处理访问CACHE失效</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'>(1)控制器如何检测CACHE失效。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> 控制器检测到失效后,通过从主存中获得信息来处理失效。如果得到的是
命中,则什么事情都不用做。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'>(2)取指令访问CACHE失效的检测和处理。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> 考虑命中是毫无意义的,失效需要我们更大的关注。如何处理指令失效可
以推广到处理数据失效。如果指令失效,指令寄存器中的内容就是无效的,接下来这个周期的执行也就变得无意义了。幸运的是这些执行都是无 害的.当我们想重新获得正确的指令时,我们必须利用从实际指令中获得的寄存器指示来重读寄存器。</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> 当我们检测到CACHE失效时,需要重新取指令,具体的步骤是:</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> a. 计算PC-4(用ALU来计算)</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> b. 使主存执行一次读操作,并等待访问完成</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> c. 写CACHE,把主存读出的数据写进CACHE映射单元的数据段中,将ALU中的高位(即
cache 中TAG地址)写进TAG字段,将VALID置为1。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> d. 重新开始,即从PC-4单元取指令,这时在CACHE中找到读指令。<br>
</span><span lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'>(3)取数据访问CACHE失效处理</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> 只需暂停CPU,等待存储器读出数据。</span></p>
<p><span lang=EN-US style='font-size:13.5pt'>5.缓存实例:DECStation 3100</span><span
lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'> 图7.7<br>
<img border=0 width=470 height=370 id="_x0000_i1027"
src="IMAGES\2。3.9.gif"></span></p>
<p><span lang=EN-US style='font-size:13.5pt'> DECStation 3100是用MIPS R2000
作为CPU的工作站,如上图所示CACHE结构。每块为一个字,这表明Index字段为14位,Tag字段为16位。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> 其体系结构如下图所示:</span><span
lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'> <img border=0 width=238
height=203 id="_x0000_i1028" src="IMAGES\2。3.3.gif"></span></p>
<p><span lang=EN-US style='font-size:13.5pt'> 最大速度执行时,在每个周期处理器同时需要指令和数据。为了满足这一需求,独立的指令CACHE和数据CACHE出现了。每个CACHE64KB即16K字,一个字为一块。</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> (1)对这两个CACHE的读请求步骤如下:</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> a.把地址送给相应的CACHE,读指令时PC是指令地址,读数据时是AIU输出的数据地址。</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> b.如果命中,CACHE中的指定单元可用。如果失效,把全地址送给主存,将主存读到的数据送进缓存。</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> (2)写CACHE 。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> 假设一个SW指令,我们仅仅将数据写进CACHE中,而不改变主存,那么主存中的数据就和CACHE中的不一样。这时我们就叫主存和CACHE不一致。解决问题的最简单的方法就是利用写通(write-through)----写CACHE的同时写主存.理解写操作的另一方面是写失效。处理器写了CACHE的某一块后,就不能够读主存到该块。事实上,我们可以
通过修改TAG字段和数据来写 CACHE,而不必考虑是写失效,还是写命中.</span><span lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'> a.用DECStation 31000解决,具体步骤如下:</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> 1)用地址的2---15位(索引)找到CACHE的字块。<br>
<br>
2)写标志(TAG)地址(31—16)和数据到字段中。</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'>
3)用31位地址把数据写到主存中。<br>
<br>
虽然这种设计很简单,但是没有提供很好的性能。每一次写操作都要花费很多的时间,这样就会降低机器的速度。例:对于GCC程序,SW指令占11。在DECStation
3100中,没有CACHE失效诸如GCC程序的CPI为1.2,每次写10时钟周期,最后的CPI=1.2+10*11=2.3,性能几乎降低了2倍。<br>
<br>
b.另解方案,采用写缓冲存储器的方法。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'> 写缓冲器的容量小于10(通常从1到小于10
的一个数)。当等待写主存时把数据送进缓冲器(write buffer)。当写主存完成时,写缓冲器就变空了.当处理器执行写指令而缓冲器是满的,处理器需等待直至缓冲器里有空位置写操作产生的速率应该比写操作执行的速率要慢,否则等待就不会发生。当写操作突然发生,就算保存的平均频率很低,等待也会发生。为了减这少些等待的出现频率,机器增加写缓冲器的宽度。例如在DECStation
3100中,写缓冲器的宽度是4个字。</span> </p>
<p><span lang=EN-US style='font-size:13.5pt'>(3)复合CACHE与二个独立的CACHE性能的比较。</span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'> 例如:设缓存的容量128K,DECS
3100两个独立的缓存之和为128K,独立缓存失效率为5.4,复合缓存失效率为4.8。前者的失效率更差一</span> <span
style='font-size:13.5pt'>些,但是前者有两倍的带宽,从而弥补了其缺点。所以,失效率不是衡量<span lang=EN-US>CACHE性能的唯一标准。</span></span>
</p>
<p><span lang=EN-US style='font-size:13.5pt'>
<br>
<br>
</span></p>
<p><span lang=EN-US style='font-size:13.5pt'><br>
<br>
</span><span lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'> </span><span
lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'> <br>
</span><span lang=EN-US> </span></p>
<p><span lang=EN-US style='font-size:13.5pt'> </span><span lang=EN-US> </span></p>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -