4.Caches
l) n# ?, i1 i, D L( j; K
2 A2 w; F2 r0 ^( | I# n, c Section 3 discussed how virtual memory extends the address space of a processor.However,the latency of real memory is too long to support high-performance processors. Even with the high-speed DRAMS used today for real memory,something must be done to overcome this latency problem.
% @! W1 y3 {4 b
The solution to this performance problem is to add another level to the memory hierarchy,called a cache,shown in Fig. 1-9.The allocation of spaces in a three-level memory is shown in Fig. 1-11.As discussed in Section 3,the virtual-address space is divided into equal-sized pages.These pages are placed in real-memory frames of the same size.Because a page can be placed in any vacant frame,there is no particular order to the allocation of pages to frames.With the addition of a cache,blocks of 16-32 bytes are taken from the page frames in real memory and placed into a block slot for access by the processor.For modern processors the cache usually has a latency of one processor clock,so that instructions and data may be fetched without delay except when the referenced item is not in the cache.
9 s; f/ l5 f: W5 f
. ~, y, |4 b) W I: N h
5.Memory Devices
# }6 M- O& S& L g9 e 1)RANDOM-ACCESS MEMORY
0 x. t' W$ S& O6 z9 R% i% ^- mRandom-access memory,or RAM,is the kind of memory we usually refer to when we speak of computer memory.It is the most widely used type,and consists of rows of chips with locations established in tables maintained by the control unit[4].
) m! Y) |: i! ~As the name suggests,items stored in RAM can be gotten(accessed)both easily and in any order(randomly)rather than in some sequence.RAM relies on electric current for all its operations;moreover,if the power is turned off or interrupted,RAM quickly empties itself of all your hard work.Thus,we say RAM is-volatile,or nonpermanent.
D6 d1 x5 w- ^* }$ D3 g
2)READ-ONLY MEMORY
7 v, {0 n( \1 a+ v
Read-only memory,or ROM,typically holds programs.These programs are manufactured,or“hard-wired”in place on the ROM chips.For example,a microcomputer has a built-in ROM chip(sometimes called ROM BIOS,for ROM basic input/output system)that stores critical programs such as the one that starts up,or“boots”,the computer.ROM is“slower”than RAM memory,and as a result,items in ROM are transferred to RAM when needed for fast processing.
; @1 u7 M. A+ g1 {% d3 JItems held in ROM can be read,but they cannot be changed or erased by normal input methods.New items cannot be written into ROM.The only way to change items in most forms of ROM is to change the actual circuits.
2 v8 Y- e. |# s8 a7 O: @, U; q% ]
3)MAGNETIC DISKS
' e0 T# k) s4 ~8 L/ c; x The magnetic disk is a circular platter with a smooth surface and a coating that can be magnetized.Data is stored on it as magnetized spots.The reading and recording device,the disk drive,spins the disk past read/write heads that detect or write the magnetized spots on the disk.
: U. M& g* |8 Z* h6 C/ H
4)CD-ROMS
) [- i: t0 c/ _
Optical disks need thin beams of concentrated light to store and read data.It is a form of laser storage,called CD-ROM.
& @, J; v; l! n9 s3 F, A
There are two types of optical disks that can he user-recorded:WORM and erasable optical.WORM stands for“write once,read many”:Data can be written to this disk just one time,but the data can be read many times.Erasable optical disks can be written to,read,and erased.
+ U: j8 H; f7 J7 K 5)MAGNETIC TAPE
0 T3 i0 o2 B4 v! T
A magnetic tape is a narrow plastic strip similar to the tape used in tape recorders.The tapes are read by tape drive moving the tape past a read/write head,which detects or writes magnetized spots on the iron-oxide coating of the tape.Each pattern of spots matches the byte code for character being stored.
! w4 R. E6 W& ~9 }) e+ ^1 J
4.高速缓冲存储器
( W3 J! S4 E6 @; X @$ i7 }& i 第3部分讨论了虚拟存储器如何扩展处理器的地址空间。但是实存储器的等待时间对高性能处理器来讲仍然太长。即使在目前很多实存储器采用高速动态随机存储器(DRAM)的情况下,为了克服这一等待时问题,还得做一些工作。
4 C% u6 X* q0 Y, {+ b 解决这一性能问题的方法是在存储层次结构中加入另外一层,称为高速缓冲存储器,如图1-9所示。图1-11显示了3级存储空间分配。正如在第3部分中所讨论的,虚拟地址空间被分为大小相同的页,这些页放在大小相同的实存储器的帧中。因为一页可以放在任何空帧中,因而对于帧而言页的放置没有具体顺序的要求。当加入了高速缓存之后,实存储器中的页帧就分成多个16~32B的数据块,这些块放到高速缓存中的块存取窗口中供处理器访问。现在的处理器中,高速缓存的等待时间只占一个处理器时钟周期,所以取数和取指令没有时延,除非要访问的数据项不在高速缓存中。
" Y# T ]( r. f. Y% [4 T% J
5.存储器
( D% H8 C' b. _- Q. H4 ] 1)随机存储器
6 o4 A: n% k9 Q$ T8 o, B9 ?: f7 H
随机存储器或称RAM,是人们常说的计算机存储器。它是使用最广的一种类型,由一组芯片构成,其存储单元由控制部件中的地址表管理。
; x. a3 W/ {9 Z 顾名思义,RAM中的内容可以很容易地以任意顺序(随机地)读出(或称访问),而不用考虑什么先来后到。RAM始终靠电流进行*作;而且,如果电源关闭或中断,RAM会很快丢失,人们辛辛苦苦存入的内容。因此人们把RAM称为易失性或非永久性的存储器。
K0 ?3 g0 v" O1 }+ x6 S: J 2)只读存储器
; t# l! X& o2 W4 P9 [4 G6 R% C. l; G
只读存储器或ROM,主要用来存储程序。这些程序是做在ROM芯片中或者说通过硬连线实现的。例如在微型计算机中就有内置ROM芯片(有时称为ROM BIOS,即ROM基本输入输出系统),该芯片存储一些关键的程序,如计算机的启动或引导程序。ROM的读取速度比RAM慢,因此如果需要快速处理,则将ROM中的内容传送到RAM中。
6 i, M% Z* d' h ROM中的内容可以读,但不能用一般的输入方法更改或擦除。新的内容也不能写入ROM。在大多数型号ROM中改变内容的惟一方法是更换实际电路。
) U) N- | B, C( c1 [ 3)磁盘
. M9 S4 Q& X" @. y. { 磁盘是一个表面光滑且涂敷可磁化材料的圆盘。数据在磁盘上作为磁化点存入。读出与记录设备即磁盘驱动器驱动磁盘转动,当通过读写磁头时,磁头从磁盘上的磁化点检测出或写入信息。
% W( {8 A) E; g# u9 E7 ^
4)只读光盘
4 ^4 }/ Z9 F, ]5 d. q7 G7 ^ v
光盘用细聚光光束去存储和读出数据。CD-ROM是激光存储器的一种形式。
; S0 l. s$ z6 |0 t 用户使用的可读写光盘有两种类型:WORM和可擦除的光盘。WORM代表一次写多次读:数据只能写入一次但可读出多次。可擦除光盘可以读、写和擦除。
8 A6 f9 `1 {7 N0 ~% @
5)磁带
. Y6 O5 b$ s' a9 ?# E
磁带是一种类似于录音磁带的窄塑料带。由磁带驱动器去读磁带的内容。驱动器驱动磁带,由读写磁头检出或写入由氧化铁涂敷的磁化点,以各磁化点的不同极性表示所存储字符的二进制代码。