Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ORGANIZATiON
soLlrTtoN
F ( S O-)1 , F ( S 1 ) = 1 - H ( S 1 ) =0.4,
F ( S 2 )= I - H ( S z ) = 0 , 2 , a n d F ( S 3 )= 1 - H ( S 3 )= 0 . 1
7: r(so)r,+ F(st;r,+ F(s2)r3
+ F(s3)lo
= ( 1 C o . r -0 . 4 r 1 A 3 + 0 . 2 x 5 0 + 0 . 1 x 1 0 0 0 ) m s
= ( 0 0 0 0 1 + 0 . 0 0 0 4+ 1 0 . 0 + 1 0 0 )m s
: 1 1 0 . 0 0 0m
5s
The hit rario Ir always lies in the closed interval 0 and It and it specificstbe
relativenumberof successfulreferencesto the cache.Equation5.7 is derivedusing the
fact that when there is a cachehit, the main memorywill not be accessed;and in the
eventof a cachemiss, both main memoryandcacrp will be accessed.Supposethc ratio
of main memory accesstime to cacheaccesstime is 1, then an expres3ionfm 0re
etficiencyof a systemthat employsa cachecan be derived-asfollows:
EfficiencY=A:*
t
ht"+(l-h)(t,+t^)
I
h+0-lr)(l+u)
tc
n+(l-&Xl+r)
I
l+r(l-tr)
Note that A is maximum when h = | iwhen all referenc€saro confinedto thc
cachc). A hit ratio of 90% (ft = 0.90) is not uncomrnonwith many cont€hPora{t,
systems.
The following exampleprovidesa qualitativeexplanation:
f
3ffi3 ale as indicated:
Calculatei, 1, and A of a memorysystemwhoseparameters
l" = 160'ns
t' = 960 ns
ft = 0.90
sotuTrot{
l=ht"+(l-h)(t"+tn)
= 0.9(160)+ (0.1X960+ 160)
= 144 + ll2
= 256ns
tm , 96{)
r=-:--1 =6
tc 160
__
_:::l
:-..
r-<:-=:-:::"'
5.6CACHE
MEMORIES zixt
A=*-=*=l=o.ozs
I +r(l -r)
-
I +6(0.1) 1.6-"
Main
memory
Cacie
memory
N-1
N Blocks
M-1
r M Blocks
Flgurc 5.16 Fully AssociativeMapping
22a MEMOFYORGANIZATION
Main
memory
i m o dN
M-1
= = 0* j r m o d l / ('.'l/modN - 0f
: ir modN
Even though there ntay be other vacant cache blocks, i2 needs to be evicted to
provide rooln for i1, and vice vcrsa. This sltuation leads to a drop in the hit ratio. This
Main
memory
Ts oio"x.
f Perset
Set
irnod (N/S)
stN/s - 1
blocksper set.This methodis practicalbecause it reducesthe sizeof th€ tag field fiom
rz bits (fully associtive)ro m - (z - s) bits. It is morc ffexiblerhandirectmrpping
becausetherc are lvls blockswithin a set (as opposedto just one block pcr sct). Fo?
this rcason,it is widely employedin many contemporary computersystemssuch.s
VAX andAmdahlcomputers(seeFigure5.21).
The following exampleis includedto explainthe mappingtechniques discusscd
so far.
I
EXAMPLE 5-3
The parameters
of a computermemorysystenarespecifiedas follows:
Detcmtne the size of the tag field of the main memoryaddressunderthe following
conditions:
e) Fully associativemaPPing
b) Direct mapping
30LUTlOt{
With the given data, compute the following:
, M = 8 K = 8 1 9 2 = 2 l 3 , a n d t h u s m= 1 3 '
. N = 512= Ze,andthusn:9'
word
. Block size = E words = 23 words, and thus we require 3 bits to specify a
within a block.
.Usingthisinformation,wecandeterminethemainandcachennemoryaddress
formats as shown next:
_ ) l
Main memoryaddress
rl{# "- l6bils
E Uits 3 611,_._-_----+l
l.---
4l I
Cachememory address
= 13 = bits:
a) In this case,the size of the tag lield is m
l- l6bits-
5.6 CACHEMEMORIES 2n
b) In this case,the size of the tag ftetd is m - n = 13 - 9 = 4bits:
If the desired information is not found in the cache, data is retrieved from the
main memory, and a block of data is transfened from the main memory to the cache.
When the CPU alters the contents of the cache, it is necessaryto update its main mem-
ory copy. There are two ways an update operation can be carried out.
In the first approach, whenever the CPU writes somethinginto a cacheblock, that
.block is tagged as a dirry block. When a dirty block is to be replaced with a new block,
the dirty block is copied into the main memory before it is overwritten by the incoming
new block. This method is called yrite-back. The virtue of this policy is that it avoids
unnecessary writing into main rnemory.
In the second method, whenever the CPU alters a cache address,the same alter-
ation is made in the main memory copy of the altered cache addressimmediately. This
technique is known as the w.rite-through rnethod. This policy can be easily imple-
mented, and it ensuresthat ihe content$of the main memory are always valid. This
feature is desirablein a multiprocessorsystem where the main memory is sharedby
severalprocessors.However, this approachmay lead to severalunnecessary writes of a
6lock to main memory befLre it is replacedin the cache.
C)neof the important aspectsof cache-memoryorganization design is to devise a
method that ensuresproper use of the cache. Usually, the tag directory contains an extra
bit for each entry. This additional bit is called a valid bit. When the power is turned
on, the vaiid bit correspondingto each cache block entry of the tag directory is reset '.o
zero. This is done to indicdtethat the cacheblock holds invalid data. When a block of
data is first transferred from the main memory to a cache block, the valid brt corre-
2to MEMORYORGANIZATION
I
s!!33!
Thc accesstirne -ofa cachememoryis 50 ns and that of the main memoryis 5(0 ns. It
is cstimatedthat t0% of the main memoryrcquestsare for lead and the remainingare
fc writc. The hit ratio for rcad'accessonly is 0.9 and a write-throughpolicy is used-
$ Dcrcrminethe averageaccesstime consideringonly the readcycles.
b) What is the averagetime if the write rcquestsarealsotakeninto consideration
SotuTrox
r)i= fu"+(l-h)(t"+t^)
= 0"9 x 50 + (0.1x550)
=45*55ns
= t(X)ns
b) tn.oe, = (readrequestprobability) x i.* + (l-read r€questprobability) X lwirc
probility = 9.9
Rcad-rcquest
Writc-requestprobability= 9.2
i,..o = i = 100ns (rcsultof Part(a))
=
iyrirc SCd)ns (becauseboth main and cachememories are updated at the same
time)
i*.,,n = 0.8 x l0o + 0.2 x 5oo
= 80 + l00ns
= lilO ns