Vous êtes sur la page 1sur 320

COMPUTER ARCHITECTURE

First Edition
M. Thangavel B.E. (CSE), M.E. (CSE)
With the Guidance of,
S. Kalpana B.Tech. (IT), M.E. (CSE)
S. Shanmuga Priya B.E. (CSE), M.E. (CSE)
Dedicated to,
M.E. Students,
Computer Science and Engineering Department,
J.J. College of Engineering & Technology,
Ammapettai, Poolangulathupatti (Post),
Tiruchirappalli - 620 009,
Tamil Nadu,
India.
SYIIABUS
CS5101 COMPUTR ARCHITCTUR
UNIT I IUNAMNTAIS OI COMPUTR SIGN
MonsurIng nnd !oorfIng Iorformnnco QunnfIfnfIvo IrIncIIos of Comufor
osIgn CInssIfyIng InsfrucfIon sof ArchIfocfuro Momory AddrossIng
AddrossIng Modos Tyo nnd SIzo of Oornnds OornfIons In fho InsfrucfIon Sof
Oornnds nnd OornfIons for ModIn nnd SIgnnI IrocossIng InsfrucfIons for
ConfroI IIow IncodIng nn InsfrucfIon Sof IxnmIo ArchIfocfuro MIIS nnd
TM32.
UNIT II INSTRUCTION IVI PARAIIIISM
IIoIInIng nnd Hnznrds Concofs of I!I ynnmIc SchoduIIng ynnmIc
Hnrdwnro IrodIcfIon MuIfIIo Issuos Hnrdwnro bnsod SocuInfIon !ImIfnfIons
of I!I Cnso SfudIos II6 MIcro ArchIfocfuro
UNIT III INSTRUCTION IVI PARAIIIISM WITH SOITWAR
APPROACH
ComIIor TochnIquos for IxosIng I!I SfnfIc Irnnch IrodIcfIon SfnfIc MuIfIIo
Issuo. V!IW Advnncod ComIIor Suorf Hnrdwnro Suorf for IxosIng
InrnIIoIIsm Hnrdwnro Vs Soffwnro SocuInfIon. MochnnIsm IA 64 nnd IfnnIum
Irocossor.
UNIT IV MMORY AN I/O
Cncho Iorformnnco !oducIng Cncho MIss IonnIfy nnd MIss !nfo !oducIng HIf
TImo MnIn
Momory nnd Iorformnnco Momory TochnoIogy Tyos of Sforngo ovIcos Iusos
!AI !oIInbIIIfy AvnIInbIIIfy nnd oondnbIIIfy I/O Iorformnnco Monsuros
osIgnIng I/O sysfom.
UNIT V MUITIPROCSSORS AN THRA IVI PARAIIIISM
SymmofrIc nnd IsfrIbufod Shnrod Momory ArchIfocfuros Iorformnnco Issuos
SynchronIznfIon ModoIs of Momory ConsIsfoncy MuIfIfhrondIng.


TABI OI CONTNTS



UnIt 1 IundumentuIs OI Computev esIgn

l.l InfroducfIon...............................
l.2 Tho ChnngIng Inco Of ComufIng
And Tho Tnsk Of Tho Comufor osIgnor.................
l.3 TochnoIogy Tronds ...........................
l.4 Cosf, IrIco And ThoIr Tronds .......................
l.5 MonsurIng And !oorfIng Iorformnnco ..................
l.6 QunnfIfnfIvo IrIncIIos Of Comufor osIgn...............
l.? InfroducfIon...............................
l.8 CInssIfyIng InsfrucfIon Sof ArchIfocfuros.................
l.9 Momory AddrossIng..........................
l.l0 AddrossIng Modos Ior SIgnnI IrocossIng...................
l.ll Tyo And SIzo Of Oornnds.........................
l.l2 Oornnds Ior ModIn And SIgnnI IrocossIng.................
l.l3 OornfIons In Tho InsfrucfIon Sof.....................
l.l4 OornfIons Ior ModIn And SIgnnI IrocossIng................
l.l5 InsfrucfIons Ior ConfroI IIow.......................
l.l6 IncodIng An InsfrucfIon Sof.......................
l.l? CrosscuffIng Issuos: Tho !oIo Of ComIIors ...................
l.l8 Tho MIIS ArchIfocfuro...........................
l.l9 Tho TrImodIn TM32 CI!..........................






00l

002
00?
009
0l3
020
028
028
033
03?
039
04l
042
043
045
049
05l
055
06l


UnIt 2 InstvuctIon IeveI PuvuIIeIIsm

2.l IIoIInIng And Hnznrds...........................
2.2 InsfrucfIon-!ovoI InrnIIoIIsm.......................
2.3 OvorcomIng nfn Hnznrds WIfh ynnmIc SchoduIIng...............
2.4 ynnmIc SchoduIIng: IxnmIos And Tho AIgorIfhm...............
2.5 !oducIng Irnnch Cosfs WIfh ynnmIc Hnrdwnro IrodIcfIon.........
2.6 HIgh Iorformnnco InsfrucfIon oIIvory....................
2.? TnkIng Advnnfngo Of Moro I!I WIfh MuIfIIo Issuo..............
2.8 Hnrdwnro-Insod SocuInfIon........................
2.9 SfudIos Of Tho !ImIfnfIons Of I!I....................
2.l0 !ImIfnfIons On I!I Ior !onIIznbIo Irocossors..............
2.ll Tho I6 MIcronrchIfocfuro.........................





063
095
l02
l08
ll0
ll6
ll9
l2l
l26
l36
l4l

UnIt 3 InstvuctIon IeveI PuvuIIeIIsm WItL SoItwuve AppvoucL

3.l InsIc ComIIor TochnIquos Ior IxosIng I!I..............
3.2 SfnfIc Irnnch IrodIcfIon...........................
3.3 SfnfIc MuIfIIo Issuo: Tho V!IW Aronch..................
3.4 Advnncod ComIIor Suorf Ior IxosIng And
IxIoIfIng I!I...............................
3.5 Hnrdwnro Suorf Ior IxosIng Moro InrnIIoIIsm Af ComIIor TImo ...
3.6 CrosscuffIng Issuos Hnrdwnro Vorsus Soffwnro
SocuInfIon MochnnIsms........................
3.? Tho InfoI IA-64 ArchIfocfuro And IfnnIum Irocossor..........




l45
l48
l50

l53
l?3

l?9
l80




UnIt 4 Memovy-HIevuvcLy esIgn

4.l InfroducfIon..............................
4.2 Cncho Iorformnnco !ovIow..........................
4.3 Cncho Iorformnnco.............................
4.4 !oducIng Cncho MIss IonnIfy.......................
4.5 !oducIng MIss !nfo..........................
4.6 !oducIng Cncho MIss IonnIfy Or MIss !nfo VIn InrnIIoIIsm.......
4.? !oducIng HIf TImo............................
4.8 MnIn Momory And OrgnnIznfIons Ior ImrovIng Iorformnnco......
4.9 Momory TochnoIogy..........................
4.l0 VIrfunI Momory...........................
4.ll IrofocfIon And IxnmIos Of VIrfunI Momory.............
4.l2 Tyos Of Sforngo Sysfoms........................
4.l3 IusosConnocfIng I/O ovIcos To CI!/Momory.............
4.l4 !oIInbIIIfy, AvnIInbIIIfy, And oondnbIIIfy................
4.l5 !nId: !odundnnf Arrnys Of InoxonsIvo Isks..............
4.l6 Irrors And InIIuros In !onI Sysfoms...................
4.l? I/O Iorformnnco Monsuros.......................
4.l? Ionchmnrks Of Sforngo Iorformnnco And AvnIInbIIIfy...........
4.l8 osIgn And I/O Sysfom In IIvo Insy IIocos................










l8?
l89
l95
l98
205
2ll
2l4
2l?
222
226
233
240
245
252
255
260
265
26?
2?2






UnIt 5 MuItIpvocessovs And TLveud-IeveI PuvuIIeIIsm

5.l InfroducfIon.................................
5.2 ChnrncforIsfIcs Of AIIcnfIon omnIns....................
5.3 SymmofrIc Shnrod Momory ArchIfocfuros......................
5.4 Iorformnnco Of SymmofrIc Shnrod-Momory MuIfIrocossors.................
5.5 IsfrIbufod Shnrod-Momory ArchIfocfuros..............................
5.6 Iorformnnco Of IsfrIbufod Shnrod-Momory MuIfIrocossors.........
5.? SynchronIznfIon...............................
5.8 ModoIs Of Momory ConsIsfoncy: An InfroducfIon...................
5.9 MuIfIfhrondIng: IxIoIfIng Thrond-!ovoI InrnIIoIIsm
WIfhIn A Irocossor ...........................







2?5
283
285
294

29?
303
305
309

3l2




Computev AvcLItectuve
TLunguveI Muvugun 1
UNIT I
IUNAMNTAIS OI COMPUTR SIGN
1.1 INTROUCTION
Comufor fochnoIogy hns mndo IncrodIbIo rogross In fho roughIy from Insf 55
yonrs. ThIs rnId rnfo of Imrovomonf hns como bofh from ndvnncos In fho fochnoIogy
usod fo buIId comufors nnd from InnovnfIon In comufor dosIgn.
urIng fho fIrsf 25 yonrs of oIocfronIc comufors, bofh forcos mndo n mnjor
confrIbufIon; buf bogInnIng In nbouf l9?0, comufor dosIgnors bocnmo InrgoIy
doondonf uon Infogrnfod cIrcuIf fochnoIogy.
urIng fho l9?0s, orformnnco confInuod fo Imrovo nf nbouf 25 fo 30 or
yonr for fho mnInfrnmos nnd mInIcomufors fhnf domInnfod fho Indusfry. Tho Info
l9?0s nffor InvonfIon of mIcrorocossor fho growfh roughIy Incronsod 35 or yonr In
orformnnco.
ThIs growfh rnfo, combInod wIfh fho cosf ndvnnfngos of n mnss-roducod
mIcrorocossor, Iod fo nn IncronsIng frncfIon of fho comufor busInoss.
In nddIfIon, fwo sIgnIfIcnnf chnngos nro obsorvod In comufor Indusfry.
IIrsf, fho vIrfunI oIImInnfIon of nssombIy Inngungo rogrnmmIng roducod fho
nood for objocf-codo comnfIbIIIfy.
Socond, fho cronfIon of sfnndnrdIzod, vondor-Indoondonf oornfIng sysfoms,
such ns !IX nnd Ifs cIono, !Inux, Ioworod fho cosf nnd rIsk of brIngIng ouf n
now nrchIfocfuro.
Thoso chnngos mndo If ossIbIo fo succossfuIIy dovoIo n now sof of
nrchIfocfuros, cnIIod RISC (!oducod InsfrucfIon Sof Comufor) nrchIfocfuros. In fho
onrIy l980s, Tho !ISC-bnsod mnchInos focusod fho nffonfIon of dosIgnors on two
cvItIcuI pevIovmunce tecLnIques, fho oxIoIfnfIon of InsfrucfIon-IovoI nrnIIoIIsm
nnd fho uso of cnchos.
Tho combInnfIon of nrchIfocfurnI nnd orgnnIznfIonnI onhnncomonfs hns Iod fo 20
yonrs of susfnInod growfh In orformnnco nf nn nnnunI rnfo of ovor 50.

Computev AvcLItectuve
TLunguveI Muvugun 2
Tho eIIect oI tLIs dvumutIc gvowtL vute hns boon fwofoId.
IIrsf, If hns sIgnIfIcnnfIy onhnncod fho cnnbIIIfy nvnIInbIo fo comufor usors.
Ior mnny nIIcnfIons, fho hIghosf orformnnco mIcrorocossors of fodny
ouforform fho suorcomufor of Ioss fhnn l0 yonrs ngo.
Socond, fhIs drnmnfIc rnfo of Imrovomonf hns Iod fo fho domInnnco of mIcro-
rocossor-bnsod comufors ncross fho onfIro rnngo of fho comufor dosIgn.

1.2 TH CHANGING IAC OI COMPUTING AN TH TASK OI TH
COMPUTR SIGNR
1960->fho domInnnf form of comufIng wns on Inrgo mnInfrnmos, mnchInos cosfIng
mIIIIons of doIInrs nnd sforod In comufor rooms wIfh muIfIIo oornfors ovorsooIng
fhoIr suorf. TyIcnI nIIcnfIons IncIudod busInoss dnfn rocossIng nnd Inrgo-scnIo
scIonfIfIc comufIng.

19?0->fho mInIcomufor, n smnIIor sIzod mnchIno InIfInIIy focusod on nIIcnfIons In
scIonfIfIc InbornforIos, buf rnIdIy brnnchIng ouf ns fho fochnoIogy of fImoshnrIng,
muIfIIo usors shnrIng n comufor InforncfIvoIy fhrough Indoondonf formInnIs,
bocnmo wIdosrond.

19B0->fho rIso of fho doskfo comufor bnsod on mIcrorocossors, In fho form of bofh
orsonnI comufors nnd worksfnfIons. Tho IndIvIdunIIy ownod doskfo comufor
roIncod fImoshnrIng nnd Iod fo fho rIso of sorvors, comufors fhnf rovIdod Inrgor-
scnIo sorvIcos such ns: roIInbIo, Iong-form fIIo sforngo nnd nccoss, Inrgor momory, nnd
moro comufIng owor.

1990->fho omorgonco of fho Infornof nnd fho worId-wIdo wob, fho fIrsf succossfuI
hnndhoId comufIng dovIcos (orsonnI dIgIfnI nssIsfnnfs or IAs), nnd fho omorgonco
of hIgh-orformnnco dIgIfnI consumor oIocfronIcs, vnryIng from vIdoo gnmos fo sof-fo
boxos.
Thoso chnngos In comufor uso hnvo Iod fo fhroo dIfforonf comufIng mnrkofs
onch chnrncforIzod by dIfforonf nIIcnfIons, roquIromonfs, nnd comufIng fochnoIogIos.
Computev AvcLItectuve
TLunguveI Muvugun 3
esktop ComputIng
oskfo sysfoms offon nro whoro fho nowosf, hIghosf orformnnco
mIcrorocossors nonr, ns woII ns whoro roconfIy cosf-roducod mIcrorocossors nnd
sysfoms nonr fIrsf.
oskfo comufIng nIso fonds fo bo ronsonnbIy woII chnrncforIzod In forms of
nIIcnfIons nnd bonchmnrkIng, fhough fho IncronsIng uso of wob-confrIc, InforncfIvo
nIIcnfIons osos now chnIIongos In orformnnco ovnIunfIon.

Sevvevs
Tho roIo of sorvors fo rovIdo Inrgor scnIo nnd moro roIInbIo fIIo nnd comufIng
sorvIcos grow. Tho omorgonco of fho worId-wIdo wob nccoIornfod fhIs frond duo fo fho
fromondous growfh In domnnd for wob sorvors nnd fho growfh In sohIsfIcnfIon of wob-
bnsod sorvIcos. Such sorvors hnvo bocomo fho bnckbono of Inrgo-scnIo onforrIso
comufIng roIncIng fho frndIfIonnI mnInfrnmo.

CLuvuctevIstIcs oI sevvevs:

1) AtoiloIiliI, ie criIicol.
Wo uso fho form nvnIInbIIIfy, whIch monns fhnf fho sysfom cnn roIInbIy nnd
offocfIvoIy rovIdo n sorvIco. ThIs form Is fo bo dIsfInguIshod from roIInbIIIfy, whIch
snys fhnf fho sysfom novor fnIIs. Inrfs of Inrgo-scnIo sysfoms unnvoIdnbIy fnII; fho
chnIIongo In n sorvor Is fo mnInfnIn sysfom nvnIInbIIIfy In fho fnco of comononf
fnIIuros, usunIIy fhrough fho uso of rodundnncy.

2) 1npIoeie on ecoloIiliI,.
Sorvor sysfoms offon grow ovor fhoIr IIfofImo In rosonso fo n growIng domnnd
for fho sorvIcos fhoy suorf or nn Incronso In funcfIonnI roquIromonfs. Thus, fho
nbIIIfy fo scnIo u fho comufIng cnncIfy, fho momory, fho sforngo, nnd fho I/O
bnndwIdfh of n sorvor nro crucInI.


Computev AvcLItectuve
TLunguveI Muvugun 4
3) 1fficienI IIrougIpuI.
Thnf Is, fho ovornII orformnnco of fho sorvorIn forms of frnnsncfIons or
mInufo or wob ngos sorvod or socondIs whnf Is crucInI. !osonsIvonoss fo nn
IndIvIdunI roquosf romnIns Imorfnnf, buf ovornII offIcIoncy nnd cosf-offocfIvonoss, ns
doformInod by how mnny roquosfs cnn bo hnndIod In n unIf fImo, nro fho koy mofrIcs
for mosf sorvors.

mbedded Computevs
Imboddod comufors, fho nnmo gIvon fo comufors Iodgod In ofhor dovIcos
whoro fho rosonco of fho comufor Is nof ImmodInfoIy obvIous.Tho rnngo of nIIcnfIon
of fhoso dovIcos goos from sImIo omboddod mIcrorocossors fhnf mIghf nonr In n
ovorydny mnchInos fo hnndhoId dIgIfnI dovIcos (such ns nImfos, coII honos, nnd
smnrf cnrds) fo vIdoo gnmos nnd dIgIfnI sof-fo boxos.
Tho nIIcnfIon cnn usunIIy bo cnrofuIIy funod for fho rocossor nnd sysfom; fhIs
rocoss somofImos IncIudos IImIfod uso of nssombIy Inngungo In koy Ioos, nIfhough
fImo-fo-mnrkof rossuros nnd good soffwnro ongInoorIng rncfIco usunIIy rosfrIcf such
nssombIy Inngungo codIng fo n smnII frncfIon of fho nIIcnfIon.
ThIs uso of nssombIy Inngungo, fogofhor wIfh fho rosonco of sfnndnrdIzod
oornfIng sysfoms, nnd n Inrgo codo bnso hns monnf fhnf InsfrucfIon sof comnfIbIIIfy
hns bocomo nn Imorfnnf concorn In fho omboddod mnrkof. SImIy uf, IIko ofhor
comufIng nIIcnfIons, soffwnro cosfs nro offon n Inrgo fncfor In fofnI cosf of nn
omboddod sysfom.
Imboddod comufors hnvo fho wIdosf rnngo of rocossIng owor nnd cosf.Irom
Iow-ond 8-bIf nnd l6-bIf rocossors fhnf mny cosf Ioss fhnn n doIInr, fo fuII 32-bIf
mIcrorocossors cnnbIo of oxocufIng 50 mIIIIon InsfrucfIons or socond fhnf cosf undor
$l0, fo hIgh-ond omboddod rocossors (fhnf cnn oxocufo n bIIIIon InsfrucfIons or
socond nnd cosf hundrods of doIInrs) for fho nowosf vIdoo gnmo or for n hIgh-ond
nofwork swIfch.
AIfhough fho rnngo of comufIng owor In fho omboddod comufIng mnrkof Is
vory Inrgo, rIco Is n koy fncfor In fho dosIgn of comufors for fhIs snco.
Computev AvcLItectuve
TLunguveI Muvugun 5
Iorformnnco roquIromonfs do oxIsf, of courso, buf fho rImnry gonI Is offon
moofIng fho orformnnco nood nf n mInImum rIco, rnfhor fhnn nchIovIng hIghor
orformnnco nf n hIghor rIco.
Tho orformnnco roquIromonf In nn omboddod nIIcnfIon Is n ronI-fImo
roquIromonf. A ronI-fImo orformnnco roquIromonf Is ono whoro n sogmonf of fho
nIIcnfIon hns nn nbsoIufo mnxImum oxocufIon fImo fhnf Is nIIowod. !onI-fImo
orformnnco fond fo bo hIghIy nIIcnfIon doondonf. If Is usunIIy monsurod usIng
kornoIs oIfhor from fho nIIcnfIon or from n sfnndnrdIzod bonchmnrk.
Two ofhor koy chnrncforIsfIcs oxIsf In mnny omboddod nIIcnfIons: fho nood fo
mInImIzo momory nnd fho nood fo mInImIzo owor.
Imboddod robIoms nro usunIIy soIvod by ono of fhroo nronchos:
!sIng n combInod hnrdwnro/soffwnro soIufIon fhnf IncIudos somo cusfom
hnrdwnro nnd fyIcnIIy n sfnndnrd omboddod rocossor.
!sIng cusfom soffwnro runnIng on nn off-fho-shoIf omboddod rocossor.
!sIng n dIgIfnI sIgnnI rocossor nnd cusfom soffwnro.

1.2.1 TH TASK OI TH COMPUTR SIGNR
Tho fnsk fho comufor dosIgnor fncos Is n comIox ono: oformIno whnf
nffrIbufos nro Imorfnnf for n now mnchIno, nnd fhon dosIgn n mnchIno fo mnxImIzo
orformnnco whIIo sfnyIng wIfhIn cosf nnd owor consfrnInfs. ThIs fnsk hns mnny
nsocfs, IncIudIng InsfrucfIon sof dosIgn, funcfIonnI orgnnIznfIon, IogIc dosIgn, nnd
ImIomonfnfIon.
Tho ImIomonfnfIon mny oncomnss Infogrnfod cIrcuIf dosIgn, nckngIng, owor,
nnd cooIIng. OfImIzIng fho dosIgn roquIros fnmIIInrIfy wIfh n vory wIdo rnngo of
fochnoIogIos, from comIIors nnd oornfIng sysfoms fo IogIc dosIgn nnd nckngIng.
Tho form comufor nrchIfocfuro offon roforrod onIy fo InsfrucfIon sof dosIgn.Tho
nrchIfocf`s or dosIgnor`s job Is much moro fhnn InsfrucfIon sof dosIgn, nnd fho fochnIcnI
hurdIos In fho ofhor nsocfs of fho rojocf nro corfnInIy ns chnIIongIng ns fhoso
oncounforod In doIng InsfrucfIon sof dosIgn. ThIs chnIIongo Is nrfIcuInrIy ncufo nf fho
rosonf whon fho dIfforoncos nmong InsfrucfIon sofs nro smnII nnd nf n fImo whon
fhoro nro fhroo rnfhor dIsfIncf nIIcnfIons nrons.
Computev AvcLItectuve
TLunguveI Muvugun 6
Ofhor nsocfs of comufor dosIgn woro cnIIod inplenenIoIion. Tho
ImIomonfnfIon of n mnchIno hns fwo comononfs: orgnnIznfIon nnd hnrdwnro. Tho
form orgonicoIion IncIudos fho hIgh-IovoI nsocfs of n comufor`s dosIgn, such ns fho
momory sysfom, fho bus sfrucfuro, nnd fho dosIgn of fho InfornnI CI!. HorJuore Is
usod fo rofor fo fho socIfIcs of n mnchIno, IncIudIng fho dofnIIod IogIc dosIgn nnd fho
nckngIng fochnoIogy of fho mnchIno.
Tho word orcIiIecIure Is Infondod fo covor nII fhroo nsocfs of comufor dosIgn
InsfrucfIon sof nrchIfocfuro, orgnnIznfIon, nnd hnrdwnro. Comufor nrchIfocfs musf
dosIgn n comufor fo moof funcfIonnI roquIromonfs ns woII ns rIco, owor, nnd
orformnnco gonIs. Tho roquIromonfs mny bo socIfIc fonfuros InsIrod by fho mnrkof.

Summuvy oI some oI tLe most Impovtunt IunctIonuI vequIvements un uvcLItect
Iuces.

Computev AvcLItectuve
TLunguveI Muvugun ?
1.3 TCHNOIOGY TRNS
Tho chnngos In fho comufor nIIcnfIons snco ovor fho Insf docndo hnvo
drnmnfIcnIIy chnngod fho mofrIcs. oskfo comufors romnIn focusod on ofImIzIng
cosf-orformnnco ns monsurod by n sIngIo usor, sorvors focus on nvnIInbIIIfy, scnInbIIIfy,
nnd fhroughuf cosf-orformnnco, nnd omboddod comufors nro drIvon by rIco nnd
offon owor Issuos. If nn InsfrucfIon sof nrchIfocfuro Is fo bo succossfuI, If musf bo
dosIgnod fo survIvo rnId chnngos In comufor fochnoIogy. An nrchIfocf musf Inn for
fochnoIogy chnngos fhnf cnn Incronso fho IIfofImo of n comufor.

Tho foIIowIng Iour ImIomonfnfIon fochnoIogIos chnngod fho comufor Indusfry:
1ntegruteJ circuit logic technologyTrnnsIsfor donsIfy Incronsos by nbouf 35 or
yonr, nnd dIo sIzo Incronsos l0 fo 20 or yonr. Tho combInod offocf Is n growfh rnfo
In frnnsIsfor counf on n chI of nbouf 55 or yonr.
SemiconJuctor DRAM . onsIfy Incronsos by bofwoon 40 nnd 60 or yonr nnd
CycIo fImo hns Imrovod vory sIowIy, docronsIng by nbouf ono-fhIrd In l0 yonrs.
InndwIdfh or chI Incronsos nbouf fwIco ns fnsf ns Infoncy docronsos. In nddIfIon,
chnngos fo fho !AM Inforfnco hnvo nIso Imrovod fho bnndwIdfh.
Mugnetic Jiok technology. iI ie ImrovIng moro fhnn l00 or yonr. IrIor fo l990,
donsIfy Incronsod by nbouf 30 or yonr, doubIIng In fhroo yonrs. If nonrs fhnf dIsk
fochnoIogy wIII confInuo fho fnsfor donsIfy growfh rnfo for somo fImo fo como. Accoss
fImo hns Imrovod by ono-fhIrd In l0 yonrs.
etuork technologyofwork orformnnco doonds bofh on fho orformnnco of
swIfchos nnd on fho orformnnco of fho frnnsmIssIon sysfom, bofh Infoncy nnd
bnndwIdfh cnn bo Imrovod, fhough roconfIy bnndwIdfh hns boon fho rImnry focus.
Ior mnny yonrs, nofworkIng fochnoIogy nonrod fo Imrovo sIowIy: for oxnmIo, If
fook nbouf l0 yonrs for Ifhornof fochnoIogy fo movo from l0 Mb fo l00 Mb. Tho
Incronsod Imorfnnco of nofworkIng hns Iod fo n fnsfor rnfo of rogross wIfh l Cb
Ifhornof bocomIng nvnIInbIo nbouf fIvo yonrs nffor l00 Mb.
Thoso rnIdIy chnngIng fochnoIogIos Imncf fho dosIgn of n mIcrorocossor fhnf
mny, wIfh sood nnd fochnoIogy onhnncomonfs, hnvo n IIfofImo of fIvo or moro yonrs.

Computev AvcLItectuve
TLunguveI Muvugun B

ScuIIng oI TvunsIstov PevIovmunce, WIves, und Powev In Integvuted CIvcuIts
Infogrnfod cIrcuIf rocossos nro chnrncforIzod by fho feoIure eice, whIch Is
docronsod from l0 mIcrons In l9?l fo 0.l8 mIcrons In 200l. SInco n frnnsIsfor Is n 2-
dImonsIonnI objocf, fho donsIfy of frnnsIsfors Incronsos qundrnfIc nIIy wIfh n IInonr
docronso In fonfuro sIzo. Tho Incronso In frnnsIsfor orformnnco, fhIs combInnfIon of
scnIIng fncfors Ionds fo n comIox InforroInfIonshI bofwoon frnnsIsfor orformnnco nnd
rocoss fonfuro sIzo.
IIrsf nroxImnfIon, frnnsIsfor orformnnco Imrovos IInonrIy wIfh docronsIng
fonfuro sIzo. In fho onrIy dnys of mIcrorocossors, fho hIghor rnfo of Imrovomonf In
donsIfy wns usod fo quIckIy movo from 4-bIf, fo 8bIf, fo l6-bIf, fo 32-bIf mIcrorocossors.
Moro roconfIy, donsIfy Imrovomonfs hnvo suorfod fho InfroducfIon of 64-bIf
mIcrorocossors ns woII ns mnny of fho InnovnfIons In IoIInIng nnd cnchos.
Tho sIgnnI doIny for n wIro Incronsos In roorfIon fo fho roducf of Ifs rosIsfnnco
nnd cnncIfnnco. As fonfuro sIzo shrInks wIros gof shorfor, buf fho rosIsfnnco nnd
cnncIfnnco or unIf Iongfh gofs worso. SInco bofh rosIsfnnco nnd cnncIfnnco doond
on dofnIIod nsocfs of fho rocoss, fho goomofry of n wIro, fho IondIng on n wIro, nnd
ovon fho ndjnconcy fo ofhor sfrucfuros.
In fho nsf fow yonrs, wIro doIny hns bocomo n mnjor dosIgn IImIfnfIon for Inrgo
Infogrnfod cIrcuIfs nnd Is offon moro crIfIcnI fhnn frnnsIsfor swIfchIng doIny. !nrgor
nnd Inrgor frncfIons of fho cIock cycIo hnvo boon consumod by fho rongnfIon doIny of
sIgnnIs on wIros. In 200l, fho IonfIum 4 broko now ground by nIIocnfIng fwo sfngos of
Ifs 20+ sfngo IoIIno jusf for rongnfIng sIgnnIs ncross fho chI.
Iowor nIso rovIdos chnIIongos ns dovIcos nro scnIod. Ior modorn CMOS
mIcrorocossors, fho domInnnf onorgy consumfIon Is In swIfchIng frnnsIsfors. Tho
onorgy roquIrod or frnnsIsfor Is roorfIonnI fo fho roducf of fho Iond cnncIfnnco of
fho frnnsIsfor, fho froquoncy of swIfchIng, nnd fho squnro of fho voIfngo. As wo movo
from ono rocoss fo fho noxf, fho Incronso In fho numbor of frnnsIsfors swIfchIng nnd
fho froquoncy wIfh whIch fhoy swIfch, domInnfos fho docronso In Iond cnncIfnnco nnd
voIfngo, IondIng fo nn ovornII growfh In owor consumfIon.

Computev AvcLItectuve
TLunguveI Muvugun 9
1.4 COST, PRIC AN THIR TRNS

In fho nsf l5 yonrs, fho uso of fochnoIogy Imrovomonfs fo nchIovo Iowor cosf,
ns woII ns Incronsod orformnnco, hns boon n mnjor fhomo In fho comufor Indusfry.
IrIco Is whnf you soII n fInIshod good for,
Cosf Is fho nmounf sonf fo roduco If, IncIudIng ovorhond.

TLe Impuct oI TIme, VoIume, CommodIIIcutIon:
Tho cosf of n mnnufncfurod comufor comononf docronsos ovor tIme ovon
wIfhouf mnjor Imrovomonfs In fho bnsIc ImIomonfnfIon fochnoIogy. Tho undorIyIng
rIncIIo fhnf drIvos cosfs down Is fho leorning curte mnnufncfurIng cosfs docronso ovor
fImo.
As nn oxnmIo of fho IonrnIng curvo In ncfIon, fho rIco or mognbyfo of !AM
dros ovor fho Iong form by 40 or yonr. Tho MIcrorocossor rIcos nIso dro ovor
tIme, buf bocnuso fhoy nro Ioss sfnndnrdIzod fhnn !AMs, fho roInfIonshI bofwoon
rIco nnd cosf Is moro comIox. In n orIod of sIgnIfIcnnf comofIfIon, rIco fonds fo
frnck cosf cIosoIy
Tho VoIume Is n socond koy fncfor In doformInIng cosf. IncronsIng voIumos nffocf
cosf In sovornI wnys.
IIrsf, fhoy docronso fho fImo noodod fo gof down fho IonrnIng curvo, whIch Is
nrfIy roorfIonnI fo fho numbor of sysfoms (or chIs) mnnufncfurod.
Socond, voIumo docronsos cosf, sInco If Incronsos urchnsIng nnd
mnnufncfurIng offIcIoncy.
As n ruIo of fhumb, somo dosIgnors hnvo osfImnfod fhnf cosf docronsos nbouf
l0 for onch doubIIng of voIumo.
Tho CommodItIes nro roducfs fhnf nro soId by muIfIIo vondors In Inrgo
voIumos nnd nro ossonfInIIy IdonfIcnI. VIrfunIIy nII fho roducfs soId on fho shoIvos of
grocory sforos nro commodIfIos, ns nro sfnndnrd !AMs, dIsks, monIfors, nnd
koybonrds. In fho nsf l0 yonrs, much of fho Iow ond of fho comufor busInoss hns
bocomo n commodIfy busInoss focusod on buIIdIng IIM-comnfIbIo ICs.
Computev AvcLItectuve
TLunguveI Muvugun 10
Thoro nro n vnrIofy of vondors fhnf shI vIrfunIIy IdonfIcnI roducfs nnd nro
hIghIy comofIfIvo. Of courso, fhIs comofIfIon docronsos fho gn bofwoon cosf nnd
soIIIng rIco, buf If nIso docronsos cosf.

Cost oI un Integvuted CIvcuIt
Tho cosf of nckngod Infogrnfod cIrcuIf Is
Tho numbor of good chIs or wnfor roquIros fIrsf IonrnIng how mnny dIos fIf on n wnfor
nnd fhon IonrnIng how fo rodIcf fho orconfngo of fhoso fhnf wIII work. Irom fhoro If
Is sImIo fo rodIcf cosf:

Tho numbor of dIos or wnfor Is bnsIcnIIy fho nron of fho wnfor dIvIdod by fho
nron of fho dIo. If cnn bo moro nccurnfoIy osfImnfod by

Tho fIrsf form Is fho rnfIo of wnfor nron (r
2
) fo dIo nron. Tho socond comonsnfos
for fho squnro og In n round hoIo robIom rocfnnguInr dIos nonr fho orIhory of
round wnfors. IvIdIng fho cIrcumforonco (J) by fho dIngonnI of n squnro dIo Is
nroxImnfoIy fho numbor of dIos nIong fho odgo. Ior oxnmIo, n wnfor 30 cm (- l2
Inch) In dInmofor roducos 225 ( 30 l.4l) = 640 l-cm dIos.

Io cosfs nro roorfIonnI fo fho fIffh (or hIghor) owor of fho dIo nron:


Computev AvcLItectuve
TLunguveI Muvugun 11
IstvIbutIon oI Cost In u System: An umpIe
IIguro shows fho nroxImnfo cosf bronkdown for n $l,000 IC In 200l. AIfhough
fho cosfs of somo nrfs of fhIs mnchIno cnn bo oxocfod fo dro ovor fImo, ofhor
comononfs, such ns fho nckngIng nnd owor suIy, hnvo IIffIo room for
Imrovomonf.


Cost Vevsus PvIceWLy TLey IIIev und By How MucL
Cosf goos fhrough n numbor of chnngos boforo If bocomos rIco, nnd fho
comufor dosIgnor shouId undorsfnnd how n dosIgn docIsIon wIII nffocf fho ofonfInI
soIIIng rIco. Ior oxnmIo, chnngIng cosf by $l000 mny chnngo rIco by $3000 fo $4000.
Tho roInfIonshI bofwoon rIco nnd voIumo cnn Incronso fho Imncf of chnngos In
cosf, osocInIIy nf fho Iow ond of fho mnrkof. TyIcnIIy, fowor comufors nro soId ns fho
rIco Incronsos. Iurfhormoro, ns voIumo docronsos, cosfs rIso, IondIng fo furfhor
Incronsos In rIco.
Computev AvcLItectuve
TLunguveI Muvugun 12
Direct cooto rofor fo fho cosfs dIrocfIy roInfod fo mnkIng n roducf. Thoso
IncIudo Inbor cosfs, urchnsIng comononfs, scrn (fho Ioffovor from yIoId), nnd
wnrrnnfy. Irocf cosf fyIcnIIy ndds l0 fo 30 fo comononf cosf.
Tho noxf nddIfIon Is cnIIod fho grooo murgin, fho comnny`s ovorhond fhnf
cnnnof bo bIIIod dIrocfIy fo ono roducf. ThIs cnn bo fhoughf of ns IndIrocf cosf. If
IncIudos fho comnny`s rosonrch nnd dovoIomonf (!&), mnrkofIng, snIos,
mnnufncfurIng oquImonf mnInfonnnco, buIIdIng ronfnI, cosf of fInnncIng, rofnx
rofIfs, nnd fnxos. Whon fho comononf cosfs nro nddod fo fho dIrocf cosf nnd gross
mnrgIn,
Ateruge oelling price ie fho monoy fhnf comos dIrocfIy fo fho comnny for onch
roducf soId. Tho gross mnrgIn Is fyIcnIIy l0 fo 45 of fho nvorngo soIIIng rIco,
doondIng on fho unIquonoss of fho roducf. Mnnufncfurors of Iow-ond ICs hnvo Iowor
gross mnrgIns for sovornI ronsons. IIrsf, fhoIr !& oxonsos nro Iowor. Socond, fhoIr
cosf of snIos Is Iowor, sInco fhoy uso IndIrocf dIsfrIbufIon by mnII, fho Infornof, hono
ordor, or rofnII sforo) rnfhor fhnn snIosooIo. ThIrd, bocnuso fhoIr roducfs nro Ioss
unIquo, comofIfIon Is moro Infonso, fhus forcIng Iowor rIcos nnd offon Iowor rofIfs,
whIch In furn Iond fo n Iowor gross mnrgIn.
Liot price nnd nvorngo soIIIng rIco nro nof fho snmo. Ono ronson for fhIs Is fhnf
comnnIos offor voIumo dIscounfs, IoworIng fho nvorngo soIIIng rIco. As orsonnI
comufors bocnmo commodIfy roducfs, fho rofnII mnrk-us hnvo drood sIgnIfIcnnfIy,
so IIsf rIco nnd nvorngo soIIIng rIco hnvo cIosod.

TLe components oI pvIce Iov u $1,000 PC.
Computev AvcLItectuve
TLunguveI Muvugun 13

Inch Incronso Is shown nIong fho boffom ns n fnx on fho rIor rIco. Tho
orconfngos of fho now rIco for nII oIomonfs nro shown on fho Ioff of onch coIumn.

1.5 MASURING AN RPORTING PRIORMANC
Tho comufor usor Is Inforosfod In roducIng reeponee Iine ( fho fImo bofwoon fho
sfnrf nnd fho comIofIon of nn ovonf) nIso roforrod fo ns execuIion Iine. Tho mnnngor of
n Inrgo dnfn rocossIng confor mny bo Inforosfod In IncronsIng IIrougIpuI( fho fofnI
nmounf of work dono In n gIvon fImo).
In comnrIng dosIgn nIfornnfIvos, wo offon wnnf fo roInfo fho orformnnco of fwo
dIfforonf mnchInos, sny X nnd Y. Tho hrnso X Is fnsfor fhnn Y Is usod horo fo monn
fhnf fho rosonso fImo or oxocufIon fImo Is Iowor on X fhnn on Y for fho gIvon fnsk. In
nrfIcuInr, X Is n fImos fnsfor fhnn Y wIII monn

SInco oxocufIon fImo Is fho rocIrocnI of orformnnco, fho foIIowIng roInfIonshI hoIds:

Tho hrnso fho fhroughuf of X Is l.3 fImos hIghor fhnn Y sIgnIfIos horo fhnf
fho numbor of fnsks comIofod or unIf fImo on mnchIno X Is l.3 fImos fho numbor
comIofod on Y.
Ivon oxocufIon fImo cnn bo dofInod In dIfforonf wnys doondIng on whnf wo
counf. Tho mosf sfrnIghfforwnrd dofInIfIon of fImo Is cnIIod uoll-clocl Iine, reeponee
Iine, or elopeeJ Iine, whIch Is fho Infoncy fo comIofo n fnsk, IncIudIng dIsk nccossos,
momory nccossos, Inuf/oufuf ncfIvIfIos, oornfIng sysfom ovorhond.


Computev AvcLItectuve
TLunguveI Muvugun 14
CLoosIng Pvogvums to vuIuute PevIovmunce
A comufor usor who runs fho snmo rogrnms dny In nnd dny ouf wouId bo fho
orfocf cnndIdnfo fo ovnIunfo n now comufor. To ovnIunfo n now sysfom fho usor wouId
sImIy comnro fho oxocufIon fImo of hor uorllooJfho mIxfuro of rogrnms nnd
oornfIng sysfom commnnds fhnf usors run on n mnchIno.
Thoro nro fIvo IovoIs of rogrnms usod In such cIrcumsfnncos, IIsfod boIow In
docronsIng ordor of nccurncy of rodIcfIon.
l. Reul upplicutiono AIfhough fho buyor mny nof know whnf frncfIon of fImo Is
sonf on fhoso rogrnms, sho knows fhnf somo usors wIII run fhom fo soIvo ronI
robIoms. IxnmIos nro comIIors for C, foxf-rocossIng soffwnro IIko Word, nnd
ofhor nIIcnfIons IIko Ihofosho. !onI nIIcnfIons hnvo Inuf, oufuf, nnd
ofIons fhnf n usor cnn soIocf whon runnIng fho rogrnm.
Thoro Is ono mnjor downsIdo fo usIng ronI nIIcnfIons ns bonchmnrks: !onI
nIIcnfIons offon oncounfor orfnbIIIfy robIoms nrIsIng from doondoncos on
fho oornfIng sysfom or comIIor. InhnncIng orfnbIIIfy offon monns modIfyIng
fho sourco nnd somofImos oIImInnfIng somo Imorfnnf ncfIvIfy, such ns
InforncfIvo grnhIcs, whIch fonds fo bo moro sysfom-doondonf.
2. MoJifieJ (or ocripteJ) upplicutionoIn mnny cnsos, ronI nIIcnfIons nro
usod ns fho buIIdIng bIock for n bonchmnrk oIfhor wIfh modIfIcnfIons fo fho
nIIcnfIon or wIfh n scrIf fhnf ncfs ns sfImuIus fo fho nIIcnfIon.
AIIcnfIons nro modIfIod for fwo rImnry ronsons: fo onhnnco orfnbIIIfy or fo
focus on ono nrfIcuInr nsocf of sysfom orformnnco. Ior oxnmIo, fo cronfo n
CI!-orIonfod bonchmnrk, I/O mny bo romovod or rosfrucfurod fo mInImIzo Ifs
Imncf on oxocufIon fImo.
ScrIfs nro usod fo roroduco InforncfIvo bohnvIor, whIch mIghf occur on n
doskfo sysfom, or fo sImuInfo comIox muIfIusor InforncfIon, whIch occurs In n
sorvor sysfom.
3. KerneloSovornI nffomfs hnvo boon mndo fo oxfrncf smnII, koy Iocos from
ronI rogrnms nnd uso fhom fo ovnIunfo orformnnco. !Ivormoro !oos nnd
!Innck nro fho bosf known oxnmIos. !nIIko ronI rogrnms, no usor wouId run
kornoI rogrnms, for fhoy oxIsf soIoIy fo ovnIunfo orformnnco.
Computev AvcLItectuve
TLunguveI Muvugun 15
KornoIs nro bosf usod fo IsoInfo orformnnco of IndIvIdunI fonfuros of n
mnchIno fo oxInIn fho ronsons for dIfforoncos In orformnnco of ronI rogrnms.
4. Toy benchmurkoToy bonchmnrks nro fyIcnIIy bofwoon l0 nnd l00 IInos of
codo nnd roduco n rosuIf fho usor nIrondy knows boforo runnIng fho foy
rogrnm.
Irogrnms IIko SIovo of Irnfosfhonos, IuzzIo, nnd QuIcksorf nro ouInr
bocnuso fhoy nro smnII, onsy fo fyo, nnd run on nImosf nny comufor. Tho bosf
uso of such rogrnms Is bogInnIng rogrnmmIng nssIgnmonfs.
5. Synthetic benchmurkoSImIInr In hIIosohy fo kornoIs, synfhofIc
bonchmnrks fry fo mnfch fho nvorngo froquoncy of oornfIons nnd oornnds of n
Inrgo sof of rogrnms. Whofsfono nnd hrysfono nro fho mosf ouInr synfhofIc
bonchmnrks.

BencLmuvk SuItes
!oconfIy, If hns bocomo ouInr fo uf fogofhor coIIocfIons of bonchmnrks fo fry
fo monsuro fho orformnnco of rocossors wIfh n vnrIofy of nIIcnfIons. Ono of fho
mosf succossfuI nffomfs fo cronfo sfnndnrdIzod bonchmnrk nIIcnfIon suIfos hns boon
fho SIIC (Sfnndnrd Iorformnnco IvnIunfIon CorornfIon), whIch hnd Ifs roofs In fho
Info l980s offorfs fo doIIvor boffor bonchmnrks for worksfnfIons. Jusf ns fho comufor
Indusfry hns ovoIvod ovor fImo, so hns fho nood for dIfforonf bonchmnrk suIfos, nnd
fhoro nro now SIIC bonchmnrks fo covor dIfforonf nIIcnfIon cInssos, ns woII ns ofhor
suIfos bnsod on fho SIIC modoI.



Computev AvcLItectuve
TLunguveI Muvugun 16
Deoktop Benchmurko
oskfo bonchmnrks dIvIdo Info fwo brond cInssos: CI! InfonsIvo bonchmnrks
nnd grnhIcs InfonsIvo bonchmnrks InfonsIvo CI! ncfIvIfy). SIIC orIgInnIIy cronfod n
bonchmnrk sof focusIng on CI! orformnnco (InIfInIIy cnIIod SIIC89), whIch hns
ovoIvod Info Ifs fourfh gonornfIon: SIIC CI!2000, whIch foIIows SIIC95, nnd
SIIC92. (IIguro l.30 on ngo 64 dIscussos fho ovoIufIon of fho bonchmnrks.)
SIIC CI!2000, summnrIzod In IIguro, consIsfs of n sof of oIovon Infogor
bonchmnrks (CIT2000) nnd fourfoon fIonfIng oInf bonchmnrks (CII2000).AIfhough
SIIC CI!2000 Is nImod nf CI! orformnnco, fwo dIfforonf fyos of grnhIcs
bonchmnrks woro cronfod by SIIC: SIIC vIoworf Is usod for bonchmnrkIng sysfoms
suorfIng fho OonC! grnhIcs IIbrnry, whIIo SIICnc consIsfs of nIIcnfIons fhnf
mnko oxfonsIvo uso of grnhIcs. SIIC vIoworf monsuros fho 3 rondorIng
orformnnco of sysfoms runnIng undor OonC! usIng n 3- modoI nnd n sorIos of
OonC! cnIIs fhnf frnnsform fho modoI. SIICnc consIsfs of runs of fhroo Inrgo
nIIcnfIons:

l. Pro/Engineer: n soIId modoIIng nIIcnfIon fhnf doos oxfonsIvo 3- rondorIng. Tho
Inuf scrIf Is n modoI of n hofocoyIng mnchIno consIsfIng of 3?0,000 frInngIos.
2. SoliJWorko 00: n 3- CA/CAM dosIgn fooI runnIng n sorIos of fIvo fosfs vnryIng
from I/O InfonsIvo fo CI! InfonsIvo. Tho Inrgo fosf Inuf Is n modoI of nn nssombIy IIno
consIsfIng of 2?6,000 frInngIos.
3. Unigruphico V15: Tho bonchmnrk Is bnsod on nn nIrcrnff modoI nnd covors n wIdo
socfrum of !nIgrnhIcs funcfIonnIIfy, IncIudIng nssombIy, drnffIng, numorIc confroI
mnchInIng, soIId modoIIng, nnd ofImIznfIon. Tho Inufs nro nII nrf of nn nIrcrnff
dosIgn.

Serter Benchmurko
Jusf ns sorvors hnvo muIfIIo funcfIons, so fhoro nro muIfIIo fyos of
bonchmnrks. Tho sImIosf bonchmnrk Is orhns n CI! fhroughuf orIonfod
bonchmnrk. SIIC CI!2000 usos fho SIIC CI! bonchmnrks fo consfrucf n sImIo
fhroughuf bonchmnrk whoro fho rocossIng rnfo of n muIfIrocossor cnn bo monsurod
Computev AvcLItectuve
TLunguveI Muvugun 1?
by runnIng muIfIIo coIos (usunIIy ns mnny ns fhoro nro CI!s) of onch SIIC CI!
bonchmnrk nnd convorfIng fho CI! fImo Info n rnfo.

ThIs Ionds fo n monsuromonf cnIIod fho SIIC!nfo. Ofhor fhnn SIIC!nfo, mosf
sorvor nIIcnfIons nnd bonchmnrks hnvo sIgnIfIcnnf I/O ncfIvIfy nrIsIng from oIfhor
dIsk or nofwork frnffIc, IncIudIng bonchmnrks for fIIo sorvor sysfoms, for wob sorvors,
nnd for dnfnbnso nnd frnnsncfIon rocossIng sysfoms. SIIC offors bofh n fIIo sorvor
bonchmnrk (SIICSIS) nnd n wob sorvor bonchmnrk (SIICWob). SIICSIS Is n
bonchmnrk for monsurIng IS (ofwork IIIo Sysfom) orformnnco usIng n scrIf of fIIo
sorvor roquosfs; If fosfs fho orformnnco of fho I/O sysfom (bofh dIsk nnd nofwork I/O)
ns woII ns fho CI!. SIICSIS Is n fhroughuf orIonfod bonchmnrk buf wIfh Imorfnnf
rosonso fImo roquIromonfs.
Computev AvcLItectuve
TLunguveI Muvugun 1B
TrnnsncfIon rocossIng bonchmnrks monsuro fho nbIIIfy of n sysfom fo hnndIo
frnnsncfIons, whIch consIsf of dnfnbnso nccossos nnd udnfos. AII fho TIC bonchmnrks
monsuro orformnnco In frnnsncfIons or socond. In nddIfIon, fhoy IncIudo n rosonso-
fImo roquIromonf, so fhnf fhroughuf orformnnco Is monsurod onIy whon fho rosonso
fImo IImIf Is mof. To modoI ronI-worId sysfoms, hIghor frnnsncfIon rnfos nro nIso
nssocInfod wIfh Inrgor sysfoms, bofh In forms of usors nnd fho dnfn bnso fhnf fho
frnnsncfIons nro nIIod fo. IInnIIy, fho sysfom cosf for n bonchmnrk sysfom musf nIso
bo IncIudod, nIIowIng nccurnfo comnrIsons of cosf-orformnnco.

EmbeJJeJ Benchmurko
Ionchmnrks for omboddod comufIng sysfoms nro In n fnr moro nnsconf sfnfo
fhnn fhoso for oIfhor doskfo or sorvor onvIronmonfs. In fncf, mnny mnnufncfurors
quofo hrysfono orformnnco, n bonchmnrk fhnf wns crIfIcIzod nnd gIvon u by doskfo
sysfoms moro fhnn l0 yonrs ngo!
As monfIonod onrIIor, fho onormous vnrIofy In omboddod nIIcnfIons, ns woII ns
dIfforoncos In orformnnco roquIromonfs (hnrd ronI-fImo, soff ronI-fImo, nnd ovornII
cosf-orformnnco), mnko fho uso of n sIngIo sof of bonchmnrks unronIIsfIc. In rncfIco,
mnny dosIgnors of omboddod sysfoms dovIso bonchmnrks fhnf rofIocf fhoIr nIIcnfIon,
oIfhor ns kornoIs or ns sfnnd-nIono vorsIons of fho onfIro nIIcnfIon.





Computev AvcLItectuve
TLunguveI Muvugun 19

Ior fhoso omboddod nIIcnfIons fhnf cnn bo chnrncforIzod woII by kornoI
orformnnco, fho bosf sfnndnrdIzod sof of bonchmnrks nonrs fo bo n now bonchmnrk
sof: fho I Imboddod MIcrorocossor Ionchmnrk ConsorfIum (or IIMIC
ronouncod ombnssy).
Tho IIMIC bonchmnrks fnII Info fIvo cInssos: nufomofIvo/IndusfrInI, consumor,
nofworkIng, offIco nufomnfIon, nnd foIocommunIcnfIons IIguro shows fho fIvo dIfforonf
nIIcnfIon cInssos, whIch IncIudo 34 bonchmnrks.

IovmuIu:
An nvorngo of fho oxocufIon fImos fhnf frncks fofnI oxocufIon fImo Is fho oriIIneIic
neon.
ToIol 1xecuIion Tine/ oriIIneIic neon.

whoro TImoi Is fho oxocufIon fImo for fho ifh rogrnm of n fofnI of n In fho workIond.

WeigIIeJ 1xecuIion Tine/ueigIIeJ oriIIneIic neon.

whoro WoIghfi Is fho froquoncy of fho ifh rogrnm In fho workIond nnd TImoi Is fho
oxocufIon fImo of fhnf rogrnm.
Avorngo normnIIzod oxocufIon fImo cnn bo oxrossod ns oIfhor nn nrIfhmofIc or
geoneIric monn. Tho formuIn for fho goomofrIc monn Is

CoomofrIc monns nIso hnvo n nIco roorfy for fwo snmIos Xi nnd Yi:


Computev AvcLItectuve
TLunguveI Muvugun 20
1.6 QUANTITATIV PRINCIPIS OI COMPUTR SIGN
Tho mosf Imorfnnf nnd orvnsIvo rIncIIo of comufor dosIgn Is fo mnko fho
common cnso fnsf In nIyIng fhIs sImIo rIncIIo, wo hnvo fo docIdo whnf fho
froquonf cnso Is nnd how much orformnnco cnn bo Imrovod by mnkIng fhnf cnso
fnsfor.
A fundnmonfnI Inw, cnIIod AnJoIl`e Iou, cnn bo usod fo qunnfIfy fhIs rIncIIo.
AmduLI's Iuw
Tho orformnnco gnIn fhnf cnn bo obfnInod by ImrovIng somo orfIon of n
comufor cnn bo cnIcuInfod usIng AmdnhI`s !nw. AmdnhI`s !nw sfnfos fhnf fho
orformnnco Imrovomonf fo bo gnInod from usIng somo fnsfor modo of oxocufIon Is
IImIfod by fho frncfIon of fho fImo fho fnsfor modo cnn bo usod. AmdnhI`s !nw dofInos
fho epeeJup fhnf cnn bo gnInod by usIng n nrfIcuInr fonfuro.
Speedup Is tLe RutIo

Soodu foIIs us how much fnsfor n fnsk wIII run usIng fho mnchIno wIfh fho
onhnncomonf ns oosod fo fho orIgInnI mnchIno. AmdnhI`s !nw gIvos us n quIck wny fo
fInd fho soodu from somo onhnncomonf, whIch doonds on fwo fncfors:
l. TIe frocIion of IIe conpuIoIion Iine in IIe originol nocIine IIoI con Ie conterIeJ Io
Iole oJtonIoge of IIe enIoncenenIIor oxnmIo, If 20 soconds of fho oxocufIon fImo of
n rogrnm fhnf fnkos 60 soconds In fofnI cnn uso nn onhnncomonf, fho frncfIon Is 20/60.
ThIs vnIuo, whIch wo wIII cnII IrncfIon onhnncod, Is nIwnys Ioss fhnn or oqunI fo l.
Computev AvcLItectuve
TLunguveI Muvugun 21
2. TIe inprotenenI goineJ I, IIe enIonceJ execuIion noJe, IIoI ie, Iou nucI foeIer
IIe Ioel uoulJ run if IIe enIonceJ noJe uere ueeJ for IIe enIire progron ThIs vnIuo
Is fho fImo of fho orIgInnI modo ovor fho fImo of fho onhnncod modo: If fho onhnncod
modo fnkos 2 soconds for somo orfIon of fho rogrnm fhnf cnn comIofoIy uso fho
modo, whIIo fho orIgInnI modo fook 5 soconds for fho snmo orfIon, fho Imrovomonf Is
5/2. Wo wIII cnII fhIs vnIuo, whIch Is nIwnys gronfor fhnn l, Soodu onhnncod.
Tho oxocufIon fImo usIng fho orIgInnI mnchIno wIfh fho onhnncod modo wIII bo
fho fImo sonf usIng fho unonhnncod orfIon of fho mnchIno Ius fho fImo sonf usIng
fho onhnncomonf:

AmdnhI`s !nw cnn sorvo ns n guIdo fo how much nn onhnncomonf wIII Imrovo
orformnnco nnd how fo dIsfrIbufo rosourcos fo Imrovo cosf/orformnnco.

TLe CPU PevIovmunce quutIon
IssonfInIIy nII comufors nro consfrucfod usIng n cIock runnIng nf n consfnnf
rnfo. Thoso dIscrofo fImo ovonfs nro cnIIod Iicle, clocl Iicle, clocl perioJe, clocle, c,clee,
or clocl c,clee. Comufor dosIgnors rofor fo fho fImo of n cIock orIod by Ifs durnfIon
(o.g., l ns) or by Ifs rnfo (o.g., l CHz). CI! fImo for n rogrnm cnn fhon bo oxrossod
fwo wnys:
Computev AvcLItectuve
TLunguveI Muvugun 22

In nddIfIon fo fho numbor of cIock cycIos noodod fo oxocufo n rogrnm, wo cnn
nIso counf fho numbor of InsfrucfIons oxocufodfho ineIrucIion poII lengII or
ineIrucIion counI (IC). If wo know fho numbor of cIock cycIos nnd fho InsfrucfIon counf
wo cnn cnIcuInfo fho nvorngo numbor of clocl c,clee per ineIrucIion (CII).
CII Is comufod ns

Iy frnnsosIng InsfrucfIon counf In fho nbovo formuIn, cIock cycIos cnn bo dofInod ns IC
X CII. ThIs nIIows us fo uso CII In fho oxocufIon fImo formuIn:

IxnndIng fho fIrsf formuIn Info fho unIfs of monsuromonf nnd InvorfIng fho cIock rnfo
shows how fho Iocos fIf fogofhor:

CPU pevIovmunce Is dependent upon tLvee cLuvuctevIstIcs:
CIock cycIo (or rnfo), cIock cycIos or InsfrucfIon, nnd InsfrucfIon counf.
Computev AvcLItectuve
TLunguveI Muvugun 23
CI! fImo Is equoll, doondonf on fhoso fhroo chnrncforIsfIcs: A l0
Imrovomonf In nny ono of fhom Ionds fo n l0 Imrovomonf In CI! fImo.
Clocl c,cle IineHnrdwnro fochnoIogy nnd orgnnIznfIon
CP1OrgnnIznfIon nnd InsfrucfIon sof nrchIfocfuro
1neIrucIion counIInsfrucfIon sof nrchIfocfuro nnd comIIor fochnoIogy

If Is usofuI In dosIgnIng fho CI! fo cnIcuInfo fho numbor of fofnI
CI! cIock cycIos ns

whoro ICi rorosonfs numbor of fImos InsfrucfIon i Is oxocufod In n rogrnm nnd CIIi
rorosonfs fho nvorngo numbor of InsfrucfIons or cIock for InsfrucfIon i. ThIs form cnn
bo usod fo oxross CI! fImo ns

MeusuvIng und ModeIIng tLe Components oI tLe CPU PevIovmunce quutIon
To uso fho CI! orformnnco oqunfIon ns n dosIgn fooI, wo nood fo bo nbIo fo monsuro
fho vnrIous fncfors.
An eIstIng pvocessov If Is onsy fo obfnIn fho oxocufIon fImo by monsuromonf, nnd
fho cIock sood Is known. Tho chnIIongo IIos In dIscovorIng fho InsfrucfIon counf or fho
CII.

Computev AvcLItectuve
TLunguveI Muvugun 24
Newev pvocessovs IncIudo counfors for bofh InsfrucfIons oxocufod nnd for cIock
cycIos.
Thoro nro fhroo gonornI cIusses oI sImuIutIon tecLnIques.
Tho fIrsf nnd sImIosf fochnIquo, nnd honco fho Ionsf cosfIy, Is pvoIIIe-bused, stutIc
modeIIng.
In fhIs fochnIquo n dynnmIc oxocufIon rofIIo of fho rogrnm Is obfnInod by ono of fhroo
mofhods:
l. Iy usIng hnrdwnro counfors on fho rocossors, whIch nro orIodIcnIIy snvod.
ThIs fochnIquo offon gIvos nn nroxImnfo rofIIo, buf ono fhnf Is wIfhIn n fow
orconf of oxncf.
2. Iy usIng Insfrumonfod oxocufIon, In whIch InsfrumonfnfIon codo Is comIIod Info
fho rogrnm. ThIs codo Is usod fo Incromonf counfors, yIoIdIng nn oxncf rofIIo.
(ThIs fochnIquo cnn nIso bo usod fo cronfo n frnco of momory nddross fhnf nro
nccossod, whIch Is usofuI for ofhor sImuInfIon fochnIquos.)
3. Iy InforrofIng fho rogrnm nf fho InsfrucfIon sof IovoI, comIIIng InsfrucfIon
counfs In fho rocoss.

Onco fho rofIIo Is obfnInod
If Is usod fo nnnIyzo fho rogrnm In n sfnfIc fnshIon by IookIng nf fho codo.
Tho fofnI InsfrucfIon counf Is onsy fo obfnIn.
To gof n dofnIIod dynnmIc InsfrucfIon mIx foIIIng whnf fyos of
InsfrucfIons woro oxocufod wIfh whnf froquoncy.
Ior sImIo rocossors, If Is ossIbIo fo comufo nn nroxImnfIon fo fho
CII.
AIfhough fhIs sImIo modoI Ignoros momory bohnvIor nnd hns sovoro IImIfs for
modoIIng comIox IoIInos, If Is n ronsonnbIo nnd vory fnsf fochnIquo for modoIIng fho
orformnnco of shorf, Infogor IoIInos, IgnorIng fho momory sysfom bohnvIor.

Computev AvcLItectuve
TLunguveI Muvugun 25


Tvuce-dvIven sImuIutIon Is n moro sohIsfIcnfod fochnIquo for modoIIng
orformnnco nnd Is nrfIcuInrIy usofuI for modoIIng momory sysfom orformnnco. In
frnco-drIvon sImuInfIon, n frnco of fho momory roforoncos oxocufod Is cronfod, usunIIy
oIfhor by sImuInfIon or by Insfrumonfod oxocufIon. Tho frnco IncIudos whnf
InsfrucfIons woro oxocufod (gIvon by fho InsfrucfIon nddross), ns woII ns fho dnfn
nddrossos nccossod.
Tho mosf common uso Is fo modoI momory sysfom orformnnco, whIch cnn bo
dono by sImuInfIng fho momory sysfom, IncIudIng fho cnchos nnd nny momory
mnnngomonf hnrdwnro usIng fho nddross frnco.
Tho fhIrd fochnIquo, whIch Is fho mosf nccurnfo nnd mosf cosfIy, Is eecutIon
dvIven sImuIutIon. In oxocufIon-drIvon sImuInfIon n dofnIIod sImuInfIon of fho
momory sysfom nnd fho rocossor IoIIno nro dono sImuIfnnoousIy. ThIs nIIows fho
oxncf modoIIng of fho InforncfIon bofwoon fho fwo, whIch Is crIfIcnI.
PvIncIpIe oI IocuIIty
Loculity of reference meuno: Irogrnms fond fo rouso dnfn nnd InsfrucfIons
fhoy hnvo usod roconfIy. A wIdoIy hoId ruIo of fhumb Is fhnf n rogrnm sonds 90 of
Ifs oxocufIon fImo In onIy l0 of fho codo. An ImIIcnfIon of IocnIIfy Is fhnf wo cnn
rodIcf wIfh ronsonnbIo nccurncy whnf InsfrucfIons nnd dnfn n rogrnm wIII uso In fho
nonr fufuro bnsod on Ifs nccossos In fho roconf nsf. !ocnIIfy of roforonco nIso nIIos fo
dnfn nccossos, fhough nof ns sfrongIy ns fo codo nccossos. Two dIfforonf fyos of IocnIIfy
hnvo boon obsorvod.
Tenporol locoliI, sfnfos fhnf roconfIy nccossod Ifoms nro IIkoIy fo bo nccossod In
fho nonr fufuro. SpoIiol locoliI, snys fhnf Ifoms whoso nddrossos nro nonr ono nnofhor
fond fo bo roforoncod cIoso fogofhor In fImo.

Computev AvcLItectuve
TLunguveI Muvugun 26


Advuntuge oI PuvuIIeIIsm
Advnnfngo of nrnIIoIIsm Is ono of fho mosf Imorfnnf mofhods for ImrovIng
orformnnco. Wo gIvo fhroo brIof oxnmIos, whIch nro oxoundod on In Infor chnfors.
Our fIrsf oxnmIo Is fho uso of nrnIIoIIsm nf fho sysfom IovoI.
To Imrovo fho fhroughuf orformnnco on n fyIcnI sorvor bonchmnrk, such ns
SIICWob or TIC, muIfIIo rocossors nnd muIfIIo dIsks cnn bo usod. Tho workIond of
hnndIIng roquosfs cnn fhon bo srond nmong fho CI!s or dIsks rosuIfIng In Imrovod
fhroughuf. ThIs Is fho ronson fhnf scnInbIIIfy Is vIowod ns n vnIunbIo nssof for sorvor
nIIcnfIons.
Af fho IovoI of nn IndIvIdunI rocossor, fnkIng ndvnnfngo of nrnIIoIIsm nmong
InsfrucfIons Is crIfIcnI fo nchIovIng hIgh orformnnco. ThIs cnn bo dono fo do fhIs Is
fhrough IoIInIng.
Tho bnsIc Idon bohInd IoIInIng Is fo ovorIn fho oxocufIon of InsfrucfIons, so ns
fo roduco fho fofnI fImo fo comIofo n soquonco of InsfrucfIons. VIowod from fho
orsocfIvo of fho CI! orformnnco oqunfIon, wo cnn fhInk of IoIInIng ns roducIng
fho CII by nIIowIng InsfrucfIons fhnf fnko muIfIIo cycIos fo ovorIn. A koy InsIghf fhnf
nIIows IoIInIng fo work Is fhnf nof ovory InsfrucfIon doonds on Ifs ImmodInfo
rodocossor, nnd fhus, oxocufIng fho InsfrucfIons comIofoIy or nrfInIIy In nrnIIoI
mny bo ossIbIo.
InrnIIoIIsm cnn nIso bo oxIoIfod nf fho IovoI of dofnIIod dIgIfnI dosIgn. Ior
oxnmIo sof nssocInfIvo cnchos uso muIfIIo bnnks of momory fhnf nro fyIcnI sonrchod
In nrnIIoI fo fInd n dosIrod Ifom. Modorn A!!s uso cnrry-Iooknhond, whIch usos
nrnIIoIIsm fo sood fho rocoss of comufIng sums from IInonr In fho numbor of bIfs In
fho oornnds fo IognrIfhmIc.


Computev AvcLItectuve
TLunguveI Muvugun 2?

IovmuIu:
MIIS or nillion ineIrucIione per eeconJ.

Ior n gIvon rogrnm, MIIS Is sImIy

Somo fInd fhIs rIghfmosf form convonIonf sInco cIock rnfo Is fIxod for n mnchIno nnd
CII Is usunIIy n smnII numbor, unIIko InsfrucfIon counf or oxocufIon fImo. !oInfIng
MIIS fo fImo,

Tho robIom wIfh usIng MIIS ns n monsuro for comnrIson Is fhroofoId:
MIIS Is doondonf on fho InsfrucfIon sof, mnkIng If dIffIcuIf fo comnro MIIS of
comufors wIfh dIfforonf InsfrucfIon sofs.
MIIS vnrIos bofwoon rogrnms on fho snmo comufor.
Mosf ImorfnnfIy, MIIS cnn vnry InvorsoIy fo orformnnco!
!oInfIvo MIIS for n mnchIno M wns dofInod bnsod on somo roforonco mnchIno ns




Computev AvcLItectuve
TLunguveI Muvugun 2B

INSTRUCTION ST PRINCIPIS AN XAMPIS
1.? INTROUCTION
ConornI uroso !ISC nrchIfocfuros (MIIS, Iowor IC, IrocIsIon
ArchIfocfuro, SIA!C),
Iour omboddod !ISC rocossors (A!M, HIfnchI SH, MIIS l6, Thumb),
Throo oIdor nrchIfocfuros (80x86, IIM 360/3?0, nnd VAX).

Deoktop computing omhnsIzos orformnnco of rogrnms wIfh Infogor nnd
fIonfIng-oInf dnfn fyos, wIfh IIffIo rognrd for rogrnm sIzo or rocossor owor
consumfIon. Ior oxnmIo, codo sIzo hns novor boon roorfod In fho four gonornfIons of
SIIC bonchmnrks.
Sertero fodny nro usod rImnrIIy for dnfnbnso, fIIo sorvor, nnd wob nIIcnfIons,
Ius somo fImoshnrIng nIIcnfIons for mnny usors. Honco, fIonfIng-oInf orformnnco
Is much Ioss Imorfnnf for orformnnco fhnn Infogors nnd chnrncfor sfrIngs, yof
vIrfunIIy ovory sorvor rocossor sfIII IncIudos fIonfIng-oInf InsfrucfIons.
EmbeJJeJ upplicutiono vnIuo cosf nnd owor, so codo sIzo Is Imorfnnf
bocnuso Ioss momory Is bofh chonor nnd Iowor owor, nnd somo cInssos of InsfrucfIons
(such ns fIonfIng oInf) mny bo ofIonnI fo roduco chI cosfs.

1.B CIASSIIYING INSTRUCTION ST ARCHITCTURS
Tho fyo of InfornnI sforngo In n rocossor fho mnjor choIcos nro n sfnck, nn
nccumuInfor, or n sof of rogIsfors.
Oornnds mny bo nnmod oxIIcIfIy or ImIIcIfIy: Tho oornnds In stuck
urchitecture nro ImIIcIfIy on fho fo of fho sfnck, nnd In nn uccumulutor
urchitecture ono oornnd Is ImIIcIfIy fho nccumuInfor.
Computev AvcLItectuve
TLunguveI Muvugun 29
Tho generul-purpooe regioter urchitectureo hnvo onIy oxIIcIf oornnds
oIfhor rogIsfors or momory IocnfIons
A bIock dIugvum oI sucL uvcLItectuves

Opevund IocutIons Iov Iouv InstvuctIon set uvcLItectuve cIusses
In (n), n To Of Sfnck rogIsfor (TOS), oInfs fo fho fo Inuf oornnd, whIch Is
combInod wIfh fho oornnd boIow. Tho fIrsf oornnd Is romovod from fho sfnck, fho
rosuIf fnkos fho Inco of fho socond oornnd, nnd TOS Is udnfod fo oInf fo fho rosuIf.
AII oornnds nro ImIIcIf. In (b), fho AccumuInfor Is bofh nn ImIIcIf Inuf
oornnd nnd n rosuIf. In (c) ono Inuf oornnd Is n rogIsfor, ono Is In momory, nnd fho
rosuIf goos fo n rogIsfor. AII oornnds nro rogIsfors In (d), nnd, IIko fho sfnck
nrchIfocfuro, cnn bo frnnsforrod fo momory onIy vIn sonrnfo InsfrucfIons: ush or o
for (n) nnd Iond or sforo for (d).Tho boIow fIguro shows how fho codo soquonco C=A+I
wouId fyIcnIIy nonr In fhoso four cInssos of InsfrucfIon sofs.
Computev AvcLItectuve
TLunguveI Muvugun 30
Tho oxIIcIf oornnds mny bo nccossod dIrocfIy from momory or mny nood fo bo
fIrsf Iondod Info fomornry sforngo, doondIng on fho cInss of nrchIfocfuro nnd choIco of
socIfIc InsfrucfIon.

TLe code sequence Iov C = A + B Iov Iouv cIusses oI InstvuctIon sets.
Thoro nro ronIIy fwo cInssos of rogIsfor comufors. Ono cInss cnn nccoss momory
ns nrf of nny InsfrucfIon, cnIIod regioter-memory uvcLItectuve, nnd fho ofhor cnn
nccoss momory onIy wIfh Iond nnd sforo InsfrucfIons, cnIIod louJ-otore ov regioter-
regioter uvcLItectuve. A fhIrd cInss, nof found In comufors shIIng fodny, koos nII
oornnds In momory nnd Is cnIIod memory-memory urchitecture.
Somo InsfrucfIon sof nrchIfocfuros hnvo moro rogIsfors fhnn n sIngIo
nccumuInfor, buf Inco rosfrIcfIons on usos of fhoso socInI rogIsfors. Such nrchIfocfuro
Is somofImos cnIIod nn ertenJeJ uccumulutor ov opeciul purpooe regioter
comufor.
InrIy comufors usod sfnck or nccumuInfor-sfyIo nrchIfocfuros, vIrfunIIy ovory
now nrchIfocfuro dosIgnod nffor l980 usos Iond-sforo rogIsfor nrchIfocfuro. Tho mnjor
ronsons for fho omorgonco of gonornI-uroso rogIsfor (CI!) comufors nro fwofoId.
IIrsf, rogIsforsIIko ofhor forms of sforngo InfornnI fo fho rocossor nro fnsfor fhnn
momory. Socond, rogIsfors nro moro offIcIonf for n comIIor fo uso fhnn ofhor forms of
InfornnI sforngo.
Ior oxnmIo, on n rogIsfor comufor fho oxrossIon (A*I)(I*C)(A*) mny bo
ovnIunfod by doIng fho muIfIIIcnfIons In nny ordor, whIch mny bo moro offIcIonf
bocnuso of fho IocnfIon of fho oornnds or bocnuso of IoIInIng concorns.

Computev AvcLItectuve
TLunguveI Muvugun 31

Two mnjor InsfrucfIon sof chnrncforIsfIcs dIvIdo CI! nrchIfocfuros. Iofh
chnrncforIsfIcs concorn fho nnfuro of oornnds for n fyIcnI nrIfhmofIc or IogIcnI
InsfrucfIon (A!! InsfrucfIon).
Tho fIrsf concorns whofhor nn A!! InsfrucfIon hns fwo or fhroo oornnds. In fho
fhroo-oornnd formnf, fho InsfrucfIon confnIns ono rosuIf oornnd nnd fwo sourco
oornnds. In fho fwo-oornnd formnf, ono of fho oornnds Is bofh n sourco nnd n rosuIf
for fho oornfIon.
Tho socond dIsfIncfIon nmong CI! nrchIfocfuros concorns how mnny of fho
oornnds mny bo momory nddrossos In A!! InsfrucfIons. Tho numbor of momory
oornnds suorfod by n fyIcnI A!! InsfrucfIon mny vnry from nono fo fhroo.
IIguro shows combInnfIons of fhoso fwo nffrIbufos wIfh oxnmIos of comufors.
AIfhough fhoro nro sovon ossIbIo combInnfIons, fhroo sorvo fo cInssIfy nonrIy nII
oxIsfIng comufors. As wo monfIonod onrIIor, fhoso fhroo nro rogIsfor-rogIsfor (nIso
cnIIod Iond-sforo), rogIsfor-momory, nnd momory-momory.


TypIcuI combInutIons oI memovy opevunds und totuI opevunds pev typIcuI
AIU InstvuctIon wItL eumpIes oI computevs.

Computev AvcLItectuve
TLunguveI Muvugun 32

Comufors wIfh no momory roforonco or A!! InsfrucfIon nro cnIIod Iond-sforo
or rogIsfor-rogIsfor comufors. InsfrucfIons wIfh muIfIIo momory oornnds or fyIcnI
A!! InsfrucfIon nro cnIIod rogIsfor-momory or momory-momory, nccordIng fo whofhor
fhoy hnvo ono or moro fhnn ono momory oornnd.
Of courso, fho foIIowIng ndvnnfngos nnd dIsndvnnfngos nro nof nbsoIufos: Thoy
nro qunIIfnfIvo nnd fhoIr ncfunI Imncf doonds on fho comIIor nnd ImIomonfnfIon
sfrnfogy. A CI! comufor wIfh momory-momory oornfIons couId onsIIy bo Ignorod by
fho comIIor nnd usod ns n rogIsfor-rogIsfor comufor. Ono of fho mosf orvnsIvo
nrchIfocfurnI Imncfs Is on InsfrucfIon oncodIng nnd fho numbor of InsfrucfIons noodod
fo orform n fnsk.

Advuntuges und dIsudvuntuges oI tLe tLvee most common types oI genevuI-
puvpose vegIstev computevs.Tho nofnfIon (m, n) monns m momory oornnds nnd n
fofnI oornnds.


Computev AvcLItectuve
TLunguveI Muvugun 33
1.9 MMORY ARSSING
Tho momory nddrossIng monns how fho objocf Is nccossod ns n funcfIon of fho
nddross fho Iongfh. Thoro nro fwo momory nddross Issuos, fIrsf ono Is ordorIng of byfos
nnd words.
Thoro nro fwo dIfforonf convonfIons for ordorIng fho byfos wIfhIn n Inrgor objocf.
!IffIo IndInn byfo ordor ufs fho byfo whoso nddross Is x...x000 nf fho Ionsf-
sIgnIfIcnnf osIfIon In fho doubIo word (fho IIffIo ond). Tho byfos nro numborod:

IIg IndInn byfo ordor ufs fho byfo whoso nddross Is x...x000 nf fho mosf-
sIgnIfIcnnf osIfIon In fho doubIo word (fho bIg ond). Tho byfos nro numborod:

!IffIo IndInn ordorIng nIso fnIIs fo mnfch normnI ordorIng of words whon sfrIngs
nro comnrod. SfrIngs nonr S!AWKCAI (bnckwnrds) In fho rogIsfors.
A socond momory Issuo Is fhnf nccossos fo objocfs Inrgor fhnn n byfo musf bo
nIIgnod. An nccoss fo nn objocf of sIzo s byfos nf byfo nddross A Is nIIgnod If A mod s = 0.
IIguro shows fho nddrossos nf whIch nn nccoss Is nIIgnod or mIsnIIgnod.
IIguro nbovo, suoso wo rond n byfo from nn nddross wIfh Ifs fhroo Iow ordor
bIfs hnvIng fho vnIuo 4. Wo wIII nood shIff rIghf 3 byfos fo nIIgn fho byfo fo fho roor
Inco In n 64-bIf rogIsfor.
oondIng on fho InsfrucfIon, fho comufor mny nIso nood fo sIgn-oxfond fho
qunnfIfy. Sforos nro onsy: onIy fho nddrossod byfos In momory mny bo nIforod. On somo
comufors n byfo, hnIf word, nnd word oornfIon doos nof nffocf fho uor orfIon of n
rogIsfor. AIfhough nII fho comufors dIscussod In fhIs book ormIf byfo, hnIf-word, nnd
word nccossos fo momory, onIy fho IIM 360/3?0, InfoI 80x86, nnd VAX suorfs A!!
oornfIons on rogIsfor oornnds nnrrowor fhnn fho fuII wIdfh.
Computev AvcLItectuve
TLunguveI Muvugun 34


AIIgned und mIsuIIgned uddvesses oI byte, LuII wovd, wovd, und doubIe wovd
obJects Iov byte uddvessed computevs.
AddvessIng Modes
Tho wny nddrossos nro socIfIod by InsfrucfIons Is cnIIod nddrossIng modos.
AddrossIng modo socIfy consfnnfs nnd rogIsfors In nddIfIon fo IocnfIons In momory.
Whon n momory IocnfIon Is usod, fho ncfunI momory nddross socIfIod by fho
nddrossIng modo Is cnIIod fho offocfIvo nddross.
IIguro shows fho mosf common nnmos for fho nddrossIng modos, fhough fho
nnmos dIffor nmong nrchIfocfuros. In fhIs fIguro, onIy ono non-C fonfuro Is usod: Tho
Ioff nrrow () Is usod for nssIgnmonf. Wo nIso uso fho nrrny Mom ns fho nnmo for mnIn
momory nnd fho nrrny !ogs for rogIsfors.
Thus, Mom|!ogs|!l]]rofors fo fho confonfs of fho momory IocnfIon whoso
nddross Is gIvon by fho confonfs of rogIsfor l (!l). !nfor, wo wIII Infroduco oxfonsIons
for nccossIng nnd frnnsforrIng dnfn smnIIor fhnn n word.
AddrossIng modos hnvo fho nbIIIfy fo sIgnIfIcnnfIy roduco InsfrucfIon counfs;
fhoy nIso ndd fo fho comIoxIfy of buIIdIng n comufor nnd mny Incronso fho nvorngo
CII (cIock cycIos or InsfrucfIon) of comufors fhnf ImIomonf fhoso modos.
Computev AvcLItectuve
TLunguveI Muvugun 35

Summuvy oI use oI memovy uddvessIng modes


SeIectIon oI uddvessIng modes wItL eumpIes, meunIng, und usuge


Computev AvcLItectuve
TLunguveI Muvugun 36
IspIucement AddvessIng Mode
In IsIncomonf-sfyIo nddrossIng modo fIIod sIzo Is Imorfnnf bocnuso fhoy
dIrocfIy nffocf fho InsfrucfIon Iongfh. IIguro shows fho monsuromonfs fnkon on fho
dnfn nccoss on n Iond-sforo nrchIfocfuro usIng our bonchmnrk rogrnms.

IspIucement vuIues uve wIdeIy dIstvIbuted.
ImmedIute ov IItevuI AddvessIng Mode:
ImmodInfo cnn bo usod In nrIfhmofIc oornfIons, In comnrIsons nnd In movos
whoro n consfnnf Is wnnfod In n rogIsfor. IIguro (l) show fho froquoncy of ImmodInfo
for fho gonornI cInssos of Infogor oornfIons In nn InsfrucfIon sof. As fIguro (2) shows,
smnII ImmodInfo vnIuos nro mosf honvIIy usod. !nrgo ImmodInfo nro somofImos usod,
howovor mosf IIkoIy In nddrossIng InsfrucfIons.

(1) About one-quuvtev oI dutu tvunsIevs und AIU opevutIons Luve un
ImmedIute opevund.
Computev AvcLItectuve
TLunguveI Muvugun 3?

(2)TLe dIstvIbutIon oI ImmedIute vuIues.

1.10 ARSSING MOS IOR SIGNAI PROCSSING
IgIfnI SIgnnI Irocossors (SIs) donI wIfh InfInIfo, confInuous sfronms of dnfn,
fhoy roufInoIy roIy on cIrcuInr buffors. Honco, ns dnfn Is nddod fo fho buffor, n oInfor Is
chockod fo soo If If Is oInfIng nf fho ond of fho buffor. If nof, If Incromonfs fho oInfor
fo fho noxf nddross; If If Is, fho oInfor Is sof Insfond fo fho sfnrf of fho buffor. SImIInr
Issuos nrIso whon omfyIng n buffor.
Ivory SI hns n moduIo or cIrcuInr nddrossIng modo fo hnndIo fhIs cnso
nufomnfIcnIIy, our fIrsf novoI SI nddrossIng modo. If koos n sfnrf rogIsfor nnd nn
ond rogIsfor wIfh ovory nddross rogIsfor, nIIowIng fho nufo-Incromonf nnd nufo-
docromonf nddrossIng modos fo rosof whon fho ronch fho ond of fho buffor. Ono
vnrInfIon mnkos nssumfIons nbouf fho buffor sIzo sfnrfIng nf nn nddross fhnf onds In
xxx00.00 nnd so usos jusf n sIngIo buffor Iongfh rogIsfor or nddross rogIsfor. Ivon
fhough SIs nro fIghfIy fnrgofod fo n smnII numbor of nIgorIfhms.

Computev AvcLItectuve
TLunguveI Muvugun 3B
Insf IourIor Trnnsform (IIT). IITs sfnrf or ond fhoIr rocossIng wIfh dnfn
shuffIod In n nrfIcuInr ordor. Ior oIghf dnfn Ifoms In n rndIx-2 IIT, fho frnnsformnfIon
Is IIsfod boIow, wIfh nddrossos In nronfhosos shown In bInnry:
0 (000
2
) 0 (000
2
)
l (00l
2
) 4 (l00
2
)
2 (0l0
2
) 2 (0l0
2
)
3 (0ll
2
) 6 (ll0
2
)
4 (l00
2
) l (00l
2
)
5 (l0l
2
) 5 (l0l
2
)
6 (ll0
2
) 3 (0ll
2
)
? (lll
2
) ? (lll
2
)

WIfhouf socInI suorf such nddross frnnsformnfIon wouId fnko nn oxfrn
momory nccoss fo gof fho now nddross, or InvoIvo n fnIr nmounf of IogIcnI InsfrucfIons fo
frnnsform fho nddross.

Tho SI soIufIon Is bnsod on fho obsorvnfIon fhnf fho rosuIfIng bInnry nddross
Is sImIy fho rovorso of fho InIfInI nddross! Ior oxnmIo, nddross l00
2
(4) bocomos
00l
2
(l). Honco, mnny SIs hnvo fhIs socond novoI nddrossIng modo bIf rovorso
nddrossIngwhoroby fho hnrdwnro rovorsos fho Iowor bIfs of fho nddross, wIfh fho
numbor of bIfs rovorsod doondIng on fho sfo of fho IIT nIgorIfhm.

IIguro shows fho sfnfIc froquoncy of dnfn nddrossIng modos In n SI for n sof of
54 IIbrnry roufInos. ThIs nrchIfocfuro hns l? nddrossIng modos for doskfo nnd sorvor
comufors nccounf for 95 of fho SI nddrossIng. osIfo monsurIng hnnd-codod
roufInos fo dorIvo IIguro, fho uso of novoI nddrossIng modo Is snrso.
Computev AvcLItectuve
TLunguveI Muvugun 39

Ivequency oI uddvessIng modes Iov TI TMS320C54 SP.
1.11 TYP AN SIZ OI OPRANS
Tho fyo of nn oornnd dosIgnnfos by oncodIng In fho ocodo or fho dnfn cnn bo
nnnofnfod wIfh fngs fhnf nro Inforrofod by fho hnrdwnro. Thoso fngs socIfy fho fyo
of fho oornnd, nnd fho oornfIon Is choson nccordIngIy.
In doskfo nnd sorvor nrchIfocfuros fho fyo of nn oornnd usunIIy
Infogor
SIngIo-rocIsIon fIonfIng oInf
Chnrncfor, nnd so on
Tho sIzo of oornnds gonornIIy
Chnrncfor (8 bIfs)
HnIf word (l6 bIfs)
Word (32 bIfs)
SIngIo-rocIsIon fIonfIng oInf (nIso l word)
oubIo-rocIsIon fIonfIng oInf (2 words)
Computev AvcLItectuve
TLunguveI Muvugun 40
Infogors nro nImosf unIvorsnIIy rorosonfod ns fwo`s comIomonf bInnry
numbors. Chnrncfors nro usunIIy In ASCII, buf fho l6bIf !nIcodo Is gnInIng ouInrIfy
wIfh fho InfornnfIonnIIznfIon of comufors. !nfII fho onrIy l980s, mosf comufor
mnnufncfurors choso fhoIr own fIonfIng-oInf rorosonfnfIon. AImosf nII comufors
sInco fhnf fImo foIIow fho snmo sfnndnrd for fIonfIng oInf, fho IIII sfnndnrd ?54.

Somo nrchIfocfuro rovIdos oornfIons on chnrncfor sfrIngs, nIfhough such
oornfIons nro usunIIy quIfo IImIfod nnd fronf onch byfo In fho sfrIng ns n sIngIo
chnrncfor. TyIcnI oornfIons suorfod on chnrncfor sfrIngs nro comnrIsons nnd
movos. Ior busInoss nIIcnfIons, somo nrchIfocfuros suorf n docImnI formnf, usunIIy
cnIIod pucked decImuI ov bInuvy-coded decImuI4 bIfs nro usod fo oncodo fho
vnIuos 09, nnd 2 docImnI dIgIfs nro nckod Info onch byfo.

umorIc chnrncfor sfrIngs nro somofImos cnIIod unnckod docImnI, nnd
oornfIonscnIIod nckIng nnd unnckIngnro usunIIy rovIdod for convorfIng bnck
nnd forfh bofwoon fhom.

Our SIIC bonchmnrks uso byfo or chnrncfor, hnIf word (shorf Infogor), word
(Infogor), doubIo word (Iong Infogor) nnd fIonfIng-oInf dnfn fyos. IIguro shows fho
dynnmIc dIsfrIbufIon of fho sIzos of objocfs roforoncod from momory for fhoso rogrnms.
IIguro usos momory roforoncos fo oxnmIno fho fyos of dnfn boIng nccossod.

Tho doubIo word dnfn fyo Is usod for doubIo-rocIsIon fIonfIng-oInf In fIonfIng-
oInf rogrnms nnd for nddrossos, sInco fho comufor usos 64-bIf nddrossos. On n 32-bIf
nddross comufor fho 64-bIf nddrossos wouId bo roIncod by 32-bIf nddrossos, nnd so
nImosf nII doubIo-word nccossos In Infogor rogrnms wouId bocomo sIngIo word
nccossos.

Computev AvcLItectuve
TLunguveI Muvugun 41

IstvIbutIon oI dutu uccesses by sIze Iov tLe bencLmuvk pvogvums

1.12 OPRANS IOR MIA AN SIGNAI PROCSSING
CrnhIcs nIIcnfIons donI wIfh 2 nnd 3 Imngos. A common 3 dnfn fyo Is
cnIIod n terIex, n dnfn sfrucfuro wIfh fhroo comononfs: x coordInnfo, y coordInnfo, n z
coordInnfo, nnd n fourfh coordInnfo (w) fo hoI wIfh coIor or hIddon surfncos. Throo
vorfIcos socIfy n grnhIcs rImIfIvo such ns n frInngIo. Vorfox vnIuos nro usunIIy 32-bIf
fIonfIng-oInf vnIuos.
AssumIng n frInngIo Is vIsIbIo, whon If Is rondorod If Is fIIIod wIfh IxoIs. Pixele
nro usunIIy 32 bIfs, usunIIy consIsfIng of four 8-bIf chnnnoIs: ! (rod), C (groon), I (bIuo)
nnd A (whIch donofos fho frnnsnroncy of fho surfnco or frnnsnroncy of fho IxoI whon
fho IxoI Is rondorod).
SIs ndd fixeJ poinI fo fho dnfn fyos dIscussod so fnr. If you fhInk of Infogors
ns hnvIng n bInnry oInf fo fho rIghf of fho Ionsf sIgnIfIcnnf bIf, fIxod oInf hns n bInnry
oInf jusf fo fho rIghf of fho sIgn bIf. Honco, fIxod-oInf dnfn nro frncfIons bofwoon -l
nnd +l.
Computev AvcLItectuve
TLunguveI Muvugun 42
XAMPI
Horo nro fhroo sImIol6-bIf nfforns:
0l00 0000 0000 0000
0000 l000 0000 0000
0l00 l000 0000 l000 Whnf vnIuos do fhoy rorosonf If fhoy nro fwo`s comIomonf
Infogors` IIxod-oInf numbors`
ANSWR
umbor rorosonfnfIon foIIs us fhnf fho I-fh dIgIf fo fho Ioff of fho bInnry oInf
rorosonfs 2I-l nnd fho I-fh dIgIf fo fho rIghf of fho bInnry oInf rorosonfs 2-I. IIrsf
nssumo fhoso fhroo nfforns nro Infogors. Thon fho bInnry oInf Is fo fho fnr rIghf, so
fhoy rorosonf 2l4, 2ll, nnd (2l4+ 2ll+ 23), or l6384, 2048, nnd l8440.
IIxod oInf Incos fho bInnry oInf jusf fo fho rIghf of fho sIgn bIf, so ns fIxod
oInf fhoso nfforns rorosonf 2-l, 2-4, nnd (2-l+ 2-4 + 2-l2). Tho frncfIons nro l/2,
l/l6, nnd (2048 + 256 + l)/4096 or 2305/4096,whIch rorosonfs nbouf 0.50000, 0.06250,
nnd 0.562?4. AIfornnfIvoIy, for nn n-bIf fwo`s-comIomonf, fIxod-oInf numbor wo couId
jusf uso fho dIvIdo fho Infogor rosonfnfIon by fho 2n-l fo dorIvo fho snmo rosuIfs:
l6384/32?68=l/2, 2048/32?68=l/l6, nnd l8440/32?68=2305/4096.
1.13 OPRATIONS IN TH INSTRUCTION ST
Tho oornfors suorfod by mosf InsfrucfIon sof nrchIfocfuros cnn bo cnfogorIzod
ns In IIguro. Ono ruIo of fhumb ncross nII nrchIfocfuros Is fhnf fho mosf wIdoIy
oxocufod InsfrucfIons nro fho sImIo oornfIons of nn InsfrucfIon sof. Ior oxnmIo
IIguro shows l0 sImIo InsfrucfIons fhnf nccounf for 96 of InsfrucfIons oxocufod for n
coIIocfIon of Infogor rogrnms runnIng on fho ouInr InfoI 80x86. Honco, fho
ImIomonfor of fhoso InsfrucfIons shouId bo suro fo mnko fhoso fnsf, ns fhoy nro fho
common cnso.
Computev AvcLItectuve
TLunguveI Muvugun 43



TLe top 10 InstvuctIons Iov tLe B0B6

1.14 OPRATIONS IOR MIA AN SIGNAI PROCSSING
ModIn rocossIng Is judgod by humnn orcofIon, fho dnfn for muIfImodIn
oornfIons Is offon much nnrrowor fhnn fho 64-bIf dnfn word of modorn doskfo nnd
sorvor rocossors.
Computev AvcLItectuve
TLunguveI Muvugun 44
A purtitioneJ uJJ oornfIon on l6-bIf dnfn wIfh n 64-bIf A!! wouId orform
four l6-bIf ndds In n sIngIo cIock cycIo. Tho oxfrn hnrdwnro cosf Is sImIy fo rovonf
cnrrIos bofwoon fho four l6-bIf nrfIfIons of fho A!!. Ior oxnmIo, such InsfrucfIons
mIghf bo usod for grnhIcnI oornfIons on IxoIs. Thoso oornfIons nro commonIy cnIIod
Single-1notruction Multiple Dutu (S1MD) or tecIor InsfrucfIons.
Mosf grnhIcs muIfImodIn nIIcnfIons uso 32-bIf fIonfIng-oInf oornfIons.
Somo comufors doubIo onk orformnnco of sIngIo-rocIsIon, fIonfIng-oInf oornfIons;
fhoy nIIow n sIngIo InsfrucfIon fo Inunch fwo 32-bIf oornfIons on oornnds found sIdo-
by-sIdo In n doubIo rocIsIon rogIsfor. Jusf ns In fho rIor cnso, fho fwo nrfIfIons musf
bo InsuInfod fo rovonf oornfIons on ono hnIf fo nffocf fho ofhor. Such fIonfIng-oInf
oornfIons nro cnIIod puireJ-oingle operutiono.
SP opevutIons:
SIs rovIdo oornfIons ns foIIows, buf fhoy chnngo fho somnnfIcs n bIf.
ArIfhmofIc nnd IogIcnI Infogor nrIfhmofIc nnd IogIcnI oornfIons: ndd, subfrncf,
nnd, or, muIfIIo, dIvIdo
nfn frnnsfor !onds-sforos (movo InsfrucfIons on comufors wIfh momory
nddrossIng)
ConfroI Irnnch, jum, rocoduro cnII nnd rofurn, frns
IIvst, bocnuso fhoy nro offon usod In ronI fImo nIIcnfIons, fhoro Is nof nn
ofIon of cnusIng nn oxcofIon on nrIfhmofIc ovorfIow. To suorf such nn unyIoIdIng
onvIronmonf, SI nrchIfocfuros uso outuruting urithmetic: If fho rosuIf Is foo Inrgo
fo bo rorosonfod, If Is sof fo fho Inrgosf rorosonfnbIo numbor, doondIng on fho sIgn
of fho rosuIf.
A second Issuo for SIs Is fhnf fhoro nro sovornI modos fo round fho wIdor
nccumuInfors Info fho nnrrowor dnfn words.
IInuIIy, fho fnrgofod kornoIs for SIs nccumuInfo n sorIos of roducfs, nnd
honco hnvo n multiply-uccumulute ov MAC inotruction. MACs nro koy fo dof
roducf oornfIons for vocfor nnd mnfrIx muIfIIIos.
Computev AvcLItectuve
TLunguveI Muvugun 45
1.15 INSTRUCTIONS IOR CONTROI IIOW
Thoro nro four dIfforonf fyos of confroI-fIow chnngo:
CondIfIonnI brnnchos
Jums
Irocoduro cnIIs
Irocoduro rofurns
Wo wnnf fo know fho roInfIvo froquoncy of fhoso ovonfs, ns onch ovonf Is
dIfforonf, mny uso dIfforonf InsfrucfIons, nnd mny hnvo dIfforonf bohnvIor. IIguro
shows fho froquoncIos of fhoso confroI-fIow InsfrucfIons for n Iond-sforo comufor
runnIng our bonchmnrks.

Bveukdown oI contvoI IIow InstvuctIons Into tLvee cIusses: cuIIs ov vetuvns,
Jumps, und condItIonuI bvuncLes.

AddvessIng modes Iov contvoI IIow InstvuctIons:
Tho dosfInnfIon nddross of n confroI fIow InsfrucfIon musf nIwnys bo socIfIod.
ThIs dosfInnfIon Is socIfIod oxIIcIfIy In fho InsfrucfIon In fho vnsf mnjorIfy of cnsos
rocoduro rofurn boIng fho mnjor oxcofIonsInco for rofurn fho fnrgof Is nof known nf
comIIo fImo. Tho mosf common wny fo socIfy fho dosfInnfIon Is fo suIy n
dIsIncomonf fhnf Is nddod fo fho rogrnm counfor, or IC.

Computev AvcLItectuve
TLunguveI Muvugun 46


To ImIomonf rofurns nnd IndIrocf jums whon fho fnrgof Is nof known nf
comIIo fImo, n mofhod ofhor fhnn IC-roInfIvo nddrossIng Is roquIrod.
Horo, fhoro musf bo n wny fo socIfy fho fnrgof dynnmIcnIIy, so fhnf If cnn
chnngo nf runfImo. ThIs dynnmIc nddross mny bo ns sImIo ns nnmIng n rogIsfor fhnf
confnIns fho fnrgof nddross; nIfornnfIvoIy, fho jum mny ormIf nny nddrossIng modo fo
bo usod fo suIy fho fnrgof nddross.
Thoso rogIsfor IndIrocf jums nro nIso usofuI for four ofhor Imorfnnf fonfuros:

Cuse ov SwItcL stutements found In mosf rogrnmmIng Inngungos (whIch
soIocf nmong ono of sovornI nIfornnfIvos);
VIvtuuI IunctIons or mofhods In objocf-orIonfod Inngungos IIko C++ or Jnvn
(whIch nIIow dIfforonf roufInos fo bo cnIIod doondIng on fho fyo of fho
nrgumonf);
HIgL ovdev IunctIons ov IunctIon poIntevs In Inngungos IIko C or C++
(whIch nIIows funcfIons fo bo nssod ns nrgumonfs gIvIng somo of fho fInvor of
objocf orIonfod rogrnmmIng), nnd
ynumIcuIIy sLuved IIbvuvIes (whIch nIIow n IIbrnry fo bo Iondod nnd IInkod
nf runfImo onIy whon If Is ncfunIIy Invokod by fho rogrnm rnfhor fhnn Iondod
nnd IInkod sfnfIcnIIy boforo fho rogrnm Is run).

In nII four cnsos fho fnrgof nddross Is nof known nf comIIo fImo, nnd honco Is
usunIIy Iondod from momory Info n rogIsfor boforo fho rogIsfor IndIrocf jum. IIguro
shows fho dIsfrIbufIon of dIsIncomonfs for IC-roInfIvo brnnchos In InsfrucfIons. Abouf
?5 of fho brnnchos nro In fho forwnrd dIrocfIon.
Computev AvcLItectuve
TLunguveI Muvugun 4?

BvuncL dIstunces In tevms oI numbev oI InstvuctIons between tLe tuvget und
tLe bvuncL InstvuctIon.

CondItIonuI BvuncL OptIons

SInco mosf chnngos In confroI fIow nro brnnchos, docIdIng how fo socIfy fho
brnnch condIfIon Is Imorfnnf. IIguro (l) shows fho fhroo rImnry fochnIquos In uso
fodny nnd fhoIr ndvnnfngos nnd dIsndvnnfngos.

Ono of fho mosf nofIconbIo roorfIos of brnnchos Is fhnf n Inrgo numbor of fho
comnrIsons nro sImIo fosfs, nnd n Inrgo numbor nro comnrIsons wIfh zoro. Thus,
somo nrchIfocfuro choosos fo fronf fhoso comnrIsons ns socInI cnsos, osocInIIy If n
comnro nnd brnnch InsfrucfIon Is boIng usod. IIguro (2) shows fho froquoncy of
dIfforonf comnrIsons usod for condIfIonnI brnnchIng.
Computev AvcLItectuve
TLunguveI Muvugun 4B


(2)Ivequency oI dIIIevent types oI compuves In condItIonuI bvuncLes

Pvoceduve InvocutIon OptIons:
Irocoduro cnIIs nnd rofurns IncIudo confroI frnnsfor nnd ossIbIy somo sfnfo
snvIng; nf n mInImum fho rofurn nddross musf bo snvod somowhoro, somofImos In n
socInI IInk rogIsfor or jusf n CI!. Somo oIdor nrchIfocfuro rovIdo n mochnnIsm fo
snvo mnny rogIsfors, whIIo nowor nrchIfocfuros roquIro fho comIIor fo gonornfo sforos
nnd Ionds for onch rogIsfor snvod nnd rosforod.

Computev AvcLItectuve
TLunguveI Muvugun 49
Thoro nro fwo bnsIc convonfIons In uso fo snvo rogIsfors: oIfhor nf fho cnII sIfo or
InsIdo fho rocoduro boIng cnIIod. CuIIev suvIng monns fhnf fho cnIIIng rocoduro
musf snvo fho rogIsfors fhnf If wnnfs rosorvod for nccoss nffor fho cnII, nnd fhus fho
cnIIod rocoduro nood nof worry nbouf rogIsfors. CuIIee suvIng Is fho oosIfo: fho
cnIIod rocoduro musf snvo fho rogIsfors If wnnfs fo uso, IonvIng fho cnIIor Is
unrosfrnInod.
Thoro nro fImos whon cnIIor snvo musf bo usod bocnuso of nccoss nfforns fo
gIobnIIy vIsIbIo vnrInbIos In fwo dIfforonf rocoduros. Ior oxnmIo, suoso wo hnvo n
rocoduro Il fhnf cnIIs rocoduro I2, nnd bofh rocoduros mnnIuInfo fho gIobnI
vnrInbIo x. If Il hnd nIIocnfod x fo n rogIsfor, If musf bo suro fo snvo x fo n IocnfIon
known by I2 boforo fho cnII fo I2.
A comIIor`s nbIIIfy fo dIscovor whon n cnIIod rocoduro mny nccoss rogIsfor-
nIIocnfod qunnfIfIos Is comIIcnfod by fho ossIbIIIfy of sonrnfo comIInfIon. Suoso
I2 mny nof fouch x buf cnn cnII nnofhor rocoduro, I3, fhnf mny nccoss x, yof I2 nnd
I3 nro comIIod sonrnfoIy. Iocnuso of fhoso comIIcnfIons, mosf comIIors wIII
consorvnfIvoIy cnIIor snvo nny vnrInbIo fhnf mny bo nccossod durIng n cnII.

1.16 NCOING AN INSTRUCTION ST:
Tho InsfrucfIons nro oncodod Info n bInnry rorosonfnfIon for oxocufIon by fho
rocossor. ThIs rorosonfnfIon nffocfs nof onIy fho sIzo of fho comIIod rogrnm; If
nffocfs fho ImIomonfnfIon of fho rocossor, whIch musf docodo fhIs rorosonfnfIon fo
quIckIy fInd fho oornfIon nnd Ifs oornnds. Tho oornfIon Is fyIcnIIy socIfIod In ono
fIoId, cnIIod fho ocodo..
Somo oIdor comufors hnvo ono fo fIvo oornnds wIfh l0 nddrossIng modos for
onch oornnd. Ior such n Inrgo numbor of combInnfIons, fyIcnIIy n sonrnfo nddross
socIfIor Is noodod for onch oornnd: fho nddross socIfIor foIIs whnf nddrossIng modo Is
usod fo nccoss fho oornnd. Af fho ofhor oxfromo nro Iond-sforo comufors wIfh onIy
ono momory oornnd nnd onIy ono or fwo nddrossIng modos; obvIousIy, In fhIs cnso, fho
nddrossIng modo cnn bo oncodod ns nrf of fho ocodo.
Computev AvcLItectuve
TLunguveI Muvugun 50
Whon oncodIng fho InsfrucfIons, fho numbor of rogIsfors nnd fho numbor of
nddrossIng modos bofh hnvo n sIgnIfIcnnf Imncf on fho sIzo of InsfrucfIons, ns fho fho
rogIsfor fIoId nnd nddrossIng modo fIoId mny nonr mnny fImos In n sIngIo InsfrucfIon.
Thoro nro sovornI comofIng forcos whon oncodIng fho InsfrucfIon sof:
Tho dosIro fo hnvo ns mnny rogIsfors nnd nddrossIng modos ns ossIbIo.
Tho Imncf of fho sIzo of fho rogIsfor nnd nddrossIng modo fIoIds on fho nvorngo
InsfrucfIon sIzo nnd honco on fho nvorngo rogrnm sIzo.
A dosIro fo hnvo InsfrucfIons oncodod Info Iongfhs fhnf wIII bo onsy fo hnndIo In
n IoIInod ImIomonfnfIon.

IIguro shows fhroo ouInr choIcos for oncodIng fho InsfrucfIon sof. Tho fIrsf wo
cnII vnrInbIo, sInco If nIIows vIrfunIIy nII nddrossIng modos fo bo wIfh nII oornfIons.
ThIs sfyIo Is bosf whon fhoro nro mnny nddrossIng modos nnd oornfIons. Tho socond
choIco wo cnII fIxod, sInco If combInos fho oornfIon nnd fho nddrossIng modo Info fho
ocodo.

TLvee busIc vuvIutIons In InstvuctIon encodIng: vuvIubIe IengtL, IIed IengtL,
und LybvId.

Computev AvcLItectuve
TLunguveI Muvugun 51
Offon fIxod oncodIng wIII hnvo onIy n sIngIo sIzo for nII InsfrucfIons; If works bosf
whon fhoro nro fow nddrossIng modos nnd oornfIons. Tho frndo-off bofwoon vnrInbIo
oncodIng nnd fIxod oncodIng Is sIzo of rogrnms vorsus onso of docodIng In fho
rocossor. VnrInbIo frIos fo uso ns fow bIfs ns ossIbIo fo rorosonf fho rogrnm, buf
IndIvIdunI InsfrucfIons cnn vnry wIdoIy In bofh sIzo nnd fho nmounf of work fo bo
orformod.

Reduced code sIze In RISCs:
As !ISC comufors sfnrfod boIng usod In omboddod nIIcnfIons, fho 32-bIf fIxod
formnf bocnmo n IInbIIIfy sInco cosf nnd honco smnIIor codo nro Imorfnnf. In rosonso,
sovornI mnnufncfurors offorod n now hybrId vorsIon of fhoIr !ISC InsfrucfIon sofs, wIfh
bofh l6-bIf nnd 32-bIf InsfrucfIons. Tho nnrrow InsfrucfIons suorf fowor oornfIons,
smnIIor nddross nnd ImmodInfo fIoIds, fowor rogIsfors, nnd fwo-nddross formnf rnfhor
fhnn fho cInssIc fhroo-nddross formnf of !ISC comufors.

1.1? CROSSCUTTING ISSUS: TH ROI OI COMPIIRS
Todny nImosf nII rogrnmmIng Is dono In hIgh-IovoI Inngungos for doskfo nnd
sorvor nIIcnfIons. ThIs dovoIomonf monns fhnf sInco mosf InsfrucfIons oxocufod nro
fho oufuf of n comIIor, nn InsfrucfIon sof nrchIfocfuro Is ossonfInIIy n comIIor fnrgof.

TLe Stvuctuve oI Recent CompIIevs
A comIIor wrIfor`s fIrsf gonI Is corrocfnossnII vnIId rogrnms musf bo comIIod
corrocfIy. Tho socond gonI Is usunIIy sood of fho comIIod codo. TyIcnIIy, n whoIo sof
of ofhor gonIs foIIows fhoso fwo, IncIudIng fnsf comIInfIon, dobuggIng suorf, nnd
InforoornbIIIfy nmong Inngungos. ormnIIy, fho nssos In fho comIIor frnnsform
hIghor-IovoI, moro nbsfrncf rorosonfnfIons Info rogrossIvoIy Iowor-IovoI
rorosonfnfIons.
IvonfunIIy If ronchos fho InsfrucfIon sof. ThIs sfrucfuro hoIs mnnngo fho
comIoxIfy of fho frnnsformnfIons nnd mnkos wrIfIng n bug-froo comIIor onsIor.

Computev AvcLItectuve
TLunguveI Muvugun 52
Tho comIoxIfy of wrIfIng n corrocf comIIor Is n mnjor IImIfnfIon on fho nmounf
of ofImIznfIon fhnf cnn bo dono. AIfhough fho muIfIIo-nss sfrucfuro hoIs roduco
comIIor comIoxIfy, If nIso monns fhnf fho comIIor musf ordor nnd orform somo
frnnsformnfIons boforo ofhors. In fho dIngrnm of fho ofImIzIng comIIor In IIguro.

CompIIevs typIcuIIy consIst oI two to Iouv pusses, wItL move LIgLIy optImIzIng
compIIevs LuvIng move pusses.

TLe compIIev consIsts oI Iouv pLuses
l. Iont end pev Iunguuge: Tho funcfIonnIIfy of fhIs hnso Is fo frnnsform hIgh
IovoI Inngungo Info common InformodInfo form. ThIs hnso funcfIonnIIy
doondonf on Inngungo nnd mnchIno Indoondonf.
2. HIgL-IeveI optImIzutIon : Tho funcfIonnIIfy of fhIs hnso Is Ioo
frnnsformnfIons nnd rocoduro InfogrnfIon. ThIs hnso somowhnf Inngungo
doondonf nnd InrgoIy mnchIno Indoondonf.
Computev AvcLItectuve
TLunguveI Muvugun 53
3. GIobuI OptImIzev : Tho funcfIonnIIfy of fhIs hnso Is IocnI nnd gIobnI
ofImIznfIons nnd rogIsfor nIIocnfIon. ThIs hnso confnIns smnII Inngungo
doondoncy nnd mnchIno doondoncIos sIIghfIy
4. Code genevutov: Tho funcfIonnIIfy of fhIs hnso mnchIno doondonf
ofImIznfIon. ThIs hnso hIghIy mnchIno doondonf nnd Inngungo Indoondonf.

OfImIznfIons orformod by modorn comIIors cnn bo cInssIfIod by fho sfyIo of
fho frnnsformnfIon, ns foIIows:
HIgL-IeveI optImIzutIons nro offon dono on fho sourco wIfh oufuf fod fo Infor
ofImIznfIon nssos.
IocuI optImIzutIons ofImIzo codo onIy wIfhIn n sfrnIghf-IIno codo frngmonf
(cnIIod n bnsIc bIock by comIIor ooIo).
GIobuI optImIzutIons oxfond fho IocnI ofImIznfIons ncross brnnchos nnd
Infroduco n sof of frnnsformnfIons nImod nf ofImIzIng Ioos.
RegIstev uIIocutIon.
Pvocessov-dependent optImIzutIons nffomf fo fnko ndvnnfngo of socIfIc
nrchIfocfurnI knowIodgo.

RegIstev AIIocutIon
!ogIsfor nIIocnfIon nIgorIfhms fodny nro bnsod on n fochnIquo cnIIod grnh
coIorIng. Tho bnsIc Idon bohInd grnh coIorIng Is fo consfrucf n grnh rorosonfIng fho
ossIbIo cnndIdnfos for nIIocnfIon fo n rogIsfor nnd fhon fo uso fho grnh fo nIIocnfo
rogIsfors. !oughIy sonkIng, fho robIom Is how fo uso n IImIfod sof of coIors so fhnf no
fwo ndjnconf nodos In n doondoncy grnh hnvo fho snmo coIor.
Tho omhnsIs In fho nronch Is fo nchIovo l00 rogIsfor nIIocnfIon of ncfIvo
vnrInbIos. Tho robIom of coIorIng n grnh In gonornI cnn fnko oxononfInI fImo ns n
funcfIon of fho sIzo of fho grnh (I-comIofo). Thoro nro hourIsfIc nIgorIfhms,
howovor, fhnf work woII In rncfIco yIoIdIng cIoso nIIocnfIons fhnf run In nonr IInonr
fImo. Crnh coIorIng works bosf whon fhoro nro nf Ionsf l6 (nnd rofornbIy moro)
gonornI-uroso rogIsfors nvnIInbIo for gIobnI nIIocnfIon for Infogor vnrInbIos nnd
nddIfIonnI rogIsfors for fIonfIng oInf.
Computev AvcLItectuve
TLunguveI Muvugun 54
!nforfunnfoIy, grnh coIorIng doos nof work vory woII whon fho numbor of
rogIsfors Is smnII bocnuso fho hourIsfIc nIgorIfhms for coIorIng fho grnh nro IIkoIy fo
fnII.

Impuct oI OptImIzutIons on PevIovmunce
Tho fyIcnI ofImIznfIons nro gIvon In IIguro. Tho Insf coIumn of IIguro IndIcnfos fho
froquoncy wIfh whIch fho IIsfod ofImIzIng frnnsforms woro nIIod fo fho sourco
rogrnm.



MuJov types oI optImIzutIons und eumpIes In eucL cIuss.

Computev AvcLItectuve
TLunguveI Muvugun 55
TLe Impuct oI CompIIev TecLnoIogy on tLe AvcLItect's ecIsIons
Tho InforncfIon of comIIors nnd hIgh-IovoI Inngungos sIgnIfIcnnfIy nffocfs how
rogrnms uso nn InsfrucfIon sof nrchIfocfuro.
Tho stuck Is usod fo nIIocnfo IocnI vnrInbIos. Tho sfnck Is grown nnd shrunk on
rocoduro cnII or rofurn, rosocfIvoIy.
Tho gIobuI dutu uveu Is usod fo nIIocnfo sfnfIcnIIy docInrod objocfs, such ns
gIobnI vnrInbIos nnd consfnnfs. A Inrgo orconfngo of fhoso objocfs nro nrrnys or
ofhor nggrognfo dnfn sfrucfuros
Tho Leup Is usod fo nIIocnfo dynnmIc objocfs fhnf do nof ndhoro fo n sfnck
dIscIIIno.
!ogIsfor nIIocnfIon Is much moro offocfIvo for sfnck-nIIocnfod objocfs fhnn for
gIobnI vnrInbIos, nnd rogIsfor nIIocnfIon Is ossonfInIIy ImossIbIo for hon-nIIocnfod
objocfs bocnuso fhoy nro nccossod wIfh oInfors.
Tho vnrInbIo n couId nof bo rogIsfor nIIocnfod ncross fho nssIgnmonf fo * wIfhouf
gonornfIng Incorrocf codo. AIInsIng cnusos n subsfnnfInI robIom bocnuso If Is offon
dIffIcuIf or ImossIbIo fo docIdo whnf objocfs n oInfor mny rofor fo. A comIIor musf bo
consorvnfIvo; somo comIIors wIII nof nIIocnfo nny IocnI vnrInbIos of n rocoduro In n
rogIsfor whon fhoro Is n oInfor fhnf mny rofor fo ono of fho IocnI vnrInbIos.

1.1B TH MIPS ARCHITCTUR
A sImIo 64-bIf Iond-sforo nrchIfocfuro cnIIod MIIS.
MIIS omhnsIzos
A sImIo Iond-sforo InsfrucfIon sof
osIgn for IoIInIng offIcIoncy (dIscussod In AondIx A), IncIudIng n fIxod
InsfrucfIon sof oncodIng
IffIcIoncy ns n comIIor fnrgof
MIIS rovIdo n good nrchIfocfurnI modoI for sfudy, nof onIy bocnuso of fho
ouInrIfy of fhIs fyo of rocossor, buf nIso bocnuso If Is nn onsy nrchIfocfuro fo
undorsfnnd.
Computev AvcLItectuve
TLunguveI Muvugun 56
In fho l5 yonrs sInco fho fIrsf MIIS rocossor, fhoro hnvo boon mnny vorsIons of
MIIS. Wo wIII uso n subsof of whnf Is now cnIIod MIIS64, whIch wIII offon nbbrovInfo
fo jusf MIIS
RegIstevs Iov MIPS
MIIS64 hns 32 64-bIf gonornI-uroso rogIsfors (CI!s), nnmod !0, !l, ., !3l.
CI!s nro nIso somofImos known ns Infogor rogIsfors. AddIfIonnIIy, fhoro Is n sof of 32
fIonfIng-oInf rogIsfors (II!s), nnmod I0, Il, ..., I3l, whIch cnn hoId 32 sIngIo-
rocIsIon (32-bIf) vnIuos or 32 doubIo-rocIsIon (64-bIf) vnIuos. (Whon hoIdIng ono
sIngIo-rocIsIon numbor, fho ofhor hnIf of fho II! Is unusod.)
Iofh sIngIo- nnd doubIo-rocIsIon fIonfIng-oInf oornfIons (32-bIf nnd 64-bIf) nro
rovIdod. MIIS nIso IncIudo InsfrucfIons fhnf oornfo on fwo sIngIo rocIsIon oornnds
In n sIngIo 64-bIf fIonfIng-oInf rogIsfor. Tho vnIuo of !0 Is nIwnys 0.
A fow socInI rogIsfors cnn bo frnnsforrod fo nnd from fho gonornI-uroso
rogIsfors. An oxnmIo Is fho fIonfIng-oInf sfnfus rogIsfor, usod fo hoId InformnfIon
nbouf fho rosuIfs of fIonfIng-oInf oornfIons. Thoro nro nIso InsfrucfIons for movIng
bofwoon n II! nnd n CI!.
utu types Iov MIPS
Tho dnfn fyos nro 8-bIf byfos, l6-bIf hnIf words, 32-bIf words, nnd 64-bIf doubIo
words for Infogor dnfn nnd 32-bIf sIngIo rocIsIon nnd 64-bIf doubIo rocIsIon for
fIonfIng oInf.
HnIf words woro nddod bocnuso fhoy nro found In Inngungos IIko C nnd ouInr
In somo rogrnms, such ns fho oornfIng sysfoms, concornod nbouf sIzo of dnfn
sfrucfuros.SIngIo-rocIsIon fIonfIng-oInf oornnds woro nddod for sImIInr ronsons. Tho
MIIS64 oornfIons work on 64-bIf Infogors nnd 32- or 64-bIf fIonfIng oInf.
Iyfos, hnIf words, nnd words nro Iondod Info fho gonornI-uroso rogIsfors wIfh
oIfhor zoros or fho sIgn bIf roIIcnfod fo fIII fho 32 bIfs of fho CI!s. Onco Iondod, fhoy
nro oornfod on wIfh fho 64-bIf Infogor oornfIons.
Computev AvcLItectuve
TLunguveI Muvugun 5?
AddvessIng modes Iov MIPS dutu tvunsIevs
Tho onIy dnfn nddrossIng modos nro ImmodInfo nnd dIsIncomonf, bofh wIfh l6-
bIf fIoIds. !ogIsfor IndIrocf Is nccomIIshod sImIy by IncIng 0 In fho l6-bIf
dIsIncomonf fIoId, nnd nbsoIufo nddrossIng wIfh n l6-bIf fIoId Is nccomIIshod by usIng
rogIsfor 0 ns fho bnso rogIsfor.
ImbrncIng zoro gIvos us four offocfIvo modos, nIfhough onIy fwo nro suorfod In
fho nrchIfocfuro. MIIS momory Is byfo nddrossnbIo In IIg IndInn modo wIfh n 64-bIf
nddross. As If Is n Iond-sforo nrchIfocfuro, nII roforoncos bofwoon momory nnd oIfhor
CI!s or II!s nro fhrough Ionds or sforos.
Momory nccossos InvoIvIng CI!s cnn bo fo n byfo, hnIf word, word, or doubIo
word. Tho II!s mny bo Iondod nnd sforod wIfh sIngIo-rocIsIon or doubIo-rocIsIon
numbors. AII momory nccossos musf bo nIIgnod.
MIPS InstvuctIon Iovmut
SInco MIIS hnvo jusf fwo nddrossIng modos, fhoso cnn bo oncodod Info fho
ocodo. AII InsfrucfIons nro 32 bIfs wIfh n 6-bIf rImnry ocodo. Tho formnfs nro sImIo
whIIo rovIdIng l6-bIf fIoIds for dIsIncomonf nddrossIng, ImmodInfo consfnnfs, or IC-
roInfIvo brnnch nddrossos.
MIPS OpevutIons
MIIS suorfs fho IIsf of sImIo oornfIons.Thoro nro four brond cInssos of
InsfrucfIons: Ionds nnd sforos, A!! oornfIons, brnnchos nnd jums, nnd fIonfIng-oInf
oornfIons. Any of fho gonornI-uroso or fIonfIng-oInf rogIsfors mny bo Iondod or
sforod, oxcof fhnf IondIng !0 hns no offocf. SIngIo-rocIsIon fIonfIng-oInf numbors
occuy hnIf n fIonfIng oInf rogIsfor. ConvorsIons bofwoon sIngIo nnd doubIo rocIsIon
musf bo dono oxIIcIfIy.
Computev AvcLItectuve
TLunguveI Muvugun 5B

InstvuctIon Iuyout Iov MIPS



Computev AvcLItectuve
TLunguveI Muvugun 59
umpIe
AssumIng fhnf !8 nnd !l0 nro 64-bIf rogIsfors:

monns fhnf fho byfo nf fho momory IocnfIon nddrossod by fho confonfs of rogIsfor !8 Is
sIgn-oxfondod fo form n 32-bIf qunnfIfy fhnf Is sforod Info fho Iowor hnIf of rogIsfor !l0.
AII A!! InsfrucfIons nro rogIsfor-rogIsfor InsfrucfIons. Tho oornfIons IncIudo
sImIo nrIfhmofIc nnd IogIcnI oornfIons: ndd, subfrncf, A, O!, XO!, nnd shIffs.
ImmodInfo forms of nII fhoso InsfrucfIons nro rovIdod usIng n l6-bIf sIgn-
oxfondod ImmodInfo. Tho oornfIon !!I (Iond uor ImmodInfo) Ionds bIfs 32 fo 4? of n
rogIsfor, whIIo soffIng fho rosf of fho rogIsfor fo 0. !!I nIIows n 32-bIf consfnnf fo bo
buIIf In fwo InsfrucfIons, or n dnfn frnnsfor usIng nny consfnnf 32-bIf nddross In ono
oxfrn InsfrucfIon.
MIPS ContvoI IIow InstvuctIons
MIIS rovIdo comnro InsfrucfIons, whIch comnro fwo rogIsfors fo soo If fho
fIrsf Is Ioss fhnn fho socond. If fho condIfIon Is fruo, fhoso InsfrucfIons Inco n l In fho
dosfInnfIon rogIsfor (fo rorosonf fruo); ofhorwIso fhoy Inco fho vnIuo 0.Iocnuso fhoso
oornfIons sof n rogIsfor, fhoy nro cnIIod sof-oqunI, sof-nof-oqunI, sof-Ioss-fhnn, nnd so
on. Thoro nro nIso ImmodInfo forms of fhoso comnros.
ConfroI Is hnndIod fhrough n sof of jums nnd n sof of brnnchos. Tho four jum
InsfrucfIons nro dIfforonfInfod by fho fwo wnys fo socIfy fho dosfInnfIon nddross nnd
by whofhor or nof n IInk Is mndo.
Two jums uso n 26-bIf offsof shIffod fwo bIfs nnd fhon roIncos fho Iowor 28 bIfs
of fho rogrnm counfor (of fho InsfrucfIon soquonfInIIy foIIowIng fho jum) fo doformIno
fho dosfInnfIon nddross. Tho ofhor fwo jum InsfrucfIons socIfy n rogIsfor fhnf
confnIns fho dosfInnfIon nddross. Thoro nro fwo fInvors of jums: InIn jum, nnd jum
nnd IInk.
Computev AvcLItectuve
TLunguveI Muvugun 60
AII brnnchos nro condIfIonnI. Tho brnnch condIfIon Is socIfIod by fho InsfrucfIon,
whIch mny fosf fho rogIsfor sourco for zoro or nonzoro; fho rogIsfor mny confnIn n dnfn
vnIuo or fho rosuIf of n comnro.Tho brnnch fnrgof nddross Is socIfIod wIfh n l6-bIf
sIgnod offsof fhnf Is nddod fo fho rogrnm counfor, whIch Is oInfIng fo fho noxf
soquonfInI InsfrucfIon. Thoro Is nIso n brnnch fo fosf fho fIonfIng-oInf sfnfus rogIsfor
for fIonfIng oInf condIfIonnI brnnchos.
MIPS IIoutIng-PoInt OpevutIons
IIonfIng-oInf InsfrucfIons mnnIuInfo fho fIonfIng-oInf rogIsfors nnd IndIcnfo
whofhor fho oornfIon fo bo orformod Is sIngIo or doubIo rocIsIon. Tho oornfIons
MOV.S nnd MOV. coy n sIngIo-rocIsIon (MOV.S) or doubIo-rocIsIon (MOV.)
fIonfIng-oInf rogIsfor fo nnofhor rogIsfor of fho snmo fyo.
Tho oornfIons MICl nnd MTCl movo dnfn bofwoon n sIngIo fIonfIng-oInf
rogIsfor nnd nn Infogor rogIsfor; movIng n doubIo-rocIsIon vnIuo fo fwo Infogor
rogIsfors roquIros fwo InsfrucfIons. ConvorsIons from Infogor fo fIonfIng oInf nro nIso
rovIdod, nnd vIco vorsn.
Tho fIonfIng-oInf oornfIons nro ndd, subfrncf, muIfIIy, nnd dIvIdo; n suffIx
Is usod for doubIo rocIsIon nnd n suffIx S Is usod for sIngIo rocIsIon (o.g., A.,
A.S, S!I., S!I.S, M!!., M!!.S, IV., IV.S). IIonfIng-oInf comnros sof n
bIf In fho socInI fIonfIng-oInf sfnfus rogIsfor fhnf cnn bo fosfod wIfh n nIr of
brnnchos: IClT nnd IClI, brnnch fIonfIng-oInf fruo nnd brnnch fIonfIng-oInf fnIso.
To gof gronfor orformnnco for grnhIcs roufInos, MIIS64 hns InsfrucfIons fhnf
orform fwo 32-bIf fIonfIng-oInf oornfIons on onch hnIf of fho 64-bIf fIonfIng oInf
rogIsfor. Thoso puireJ oingle oornfIons IncIudo A.IS, S!I.IS, M!!.IS, nnd
IV.IS. (Thoy nro Iondod nnd sforo usIng doubIo rocIsIon Ionds nnd sforos.)
CIvIng n nod fownrds fho Imorfnnco of SI nIIcnfIons, MIIS64 nIso IncIudos
bofh Infogor nnd fIonfIng-oInf muIfIIy-ndd InsfrucfIons: MA, MA.S, MA.,
nnd MA.IS.

Computev AvcLItectuve
TLunguveI Muvugun 61
1.19 TH TRIMIA TM32 CPU
ModIn rocossor Is n nnmo gIvon fo n cInss of omboddod rocossors fhnf nro
dodIcnfod fo muIfImodIn rocossIng, fyIcnIIy boIng cosf sonsIfIvo IIko omboddod
rocossors buf foIIowIng fho comIIor orIonfnfIon from doskfo nnd sorvor comufIng.
!Iko SIs, fhoy oornfo on nnrrowor dnfn fyos fhnn fho doskfo, nnd musf offon donI
wIfh InfInIfo, confInuous sfronms of dnfn.

Tho TrImodIn TM32 CI! Is n rorosonfnfIvo of fhIs cInss. As muIfImodIn
nIIcnfIons hnvo consIdornbIo nrnIIoIIsm In fho rocossIng of fhoso dnfn sfronms, fho
InsfrucfIon sof nrchIfocfuros offon Iook dIfforonf from fho doskfo. If Is Infondod for
roducfs IIko sof fo boxos nnd ndvnncod foIovIsIons.
IIrsf, fhoro nro mnny moro rogIsfors: l28 32-bIf rogIsfors, whIch confnIn oIfhor
Infogor or fIonfIng oInf dnfn. Socond, nnd nof surrIsIngIy, If offors fho nrfIfIonod
A!! or SIM InsfrucfIons fo nIIow comufnfIons on muIfIIo Insfnncos of nnrrowor
dnfn.ThIrd, showIng Ifs horIfngo, for Infogors If offors bofh fwo`s comIomonf nrIfhmofIc
fnvorod by doskfo rocossors nnd snfurnfIng nrIfhmofIc fnvorod by SIs.
If fhoro nro nof fIvo Indoondonf InsfrucfIons nvnIInbIo for fho comIIor fo
schoduIo fogofhorfhnf Is, fho rosf nro doondonffhon OIs nro Incod In fho Ioffovor
sIofs. ThIs InsfrucfIon codIng fochnIquo Is cnIIod, nnfurnIIy onough, Ver, Iong
1neIrucIion WorJ (VI1W), nnd If rodnfos fho TrImodIn rocossors.
Tho TrImodIn TM32 CI! hns Iongor InsfrucfIon words nnd fhoy offon confnIn
OIs, TrImodIn comncfs Ifs InsfrucfIons In momory, docodIng fhom fo fho fuII sIzo
whon Iondod Info fho cncho.
Computev AvcLItectuve
TLunguveI Muvugun 62
Tho cosf In codo sIzo of fhoso V!IW InsfrucfIons Is sfIII n fncfor of fwo fo fhroo
Inrgor fhnn MIIS ofIer comncfIon.

IIst oI opevutIons und numbev oI vuvIutIons In TvImedIu TM32 CPU.
CIvon fho TrImodIn TM32 CI! hns Iongor InsfrucfIon words nnd fhoy offon
confnIn OIs, TrImodIn comncfs Ifs InsfrucfIons In momory, docodIng fhom fo fho fuII
sIzo whon Iondod Info fho cncho.IIguro shows fho TM32 CI! InsfrucfIon mIx for fho
IIMIC bonchmnrks. !sIng fho unmodIfIod sourco codo, fho InsfrucfIon mIx Is sImIInr
fo ofhors, nIfhough fhoro nro moro byfo dnfn frnnsfors. If fho C codo Is hnnd-funod, If
cnn oxfonsIvoIy uso SIM InsfrucfIons. ofo fho Inrgo numbor of nck nnd morgo
InsfrucfIons fo nIIgn fho dnfn for fho SIM InsfrucfIons. Tho cosf In codo sIzo of fhoso
V!IW InsfrucfIons Is sfIII n fncfor of fwo fo fhroo Inrgor fhnn MIIS ofIer comncfIon.


***N***

Computev AvcLItectuve
TLunguveI Muvugun 63
UNIT II
INSTRUCTION IVI PARAIIIISM
2.1 PIPIINING AN HAZARS
Pipelining Is nn ImIomonfnfIon fochnIquo whoroby muIfIIo InsfrucfIons nro
ovorInod In oxocufIon; If fnkos ndvnnfngo of nrnIIoIIsm fhnf oxIsfs nmong fho ncfIons
noodod fo oxocufo nn InsfrucfIon.
A IoIIno Is IIko nn nssombIy IIno. In n comufor IoIIno, onch sfo In fho
IoIIno comIofos n nrf of nn InsfrucfIon. !Iko fho nssombIy IIno, dIfforonf sfos nro
comIofIng dIfforonf nrfs of dIfforonf InsfrucfIons In nrnIIoI. Inch of fhoso sfos Is
cnIIod n pipe eIoge or n pipe eegnenI. Tho sfngos nro connocfod ono fo fho noxf fo form n
IoInsfrucfIons onfor nf ono ond, rogross fhrough fho sfngos, nnd oxIf nf fho ofhor
ond.
Tho fhroughuf of nn InsfrucfIon IoIIno Is doformInod by how offon nn
InsfrucfIon oxIfs fho IoIIno. Tho fImo roquIrod bofwoon movIng nn InsfrucfIon ono
sfo down fho IoIIno Is n proceeeor c,cle. Iocnuso nII sfngos rocood nf fho snmo fImo,
fho Iongfh of n rocossor cycIo Is doformInod by fho fImo roquIrod for fho sIowosf Io
sfngo.
Tho IoIIno dosIgnor`s gonI Is fo bnInnco fho Iongfh of onch IoIIno sfngo. If fho
sfngos nro orfocfIy bnInncod, fhon fho fImo or InsfrucfIon on fho IoIInod
rocossornssumIng IdonI condIfIonsIs oqunI fo

Tho soodu from IoIInIng oqunIs fho numbor of Io sfngos. Tho sfngos wIII
nof bo orfocfIy bnInncod; furfhormoro, IoIInIng doos InvoIvo somo ovorhond. Thus,
fho fImo or InsfrucfIon on fho IoIInod rocossor wIII nof hnvo Ifs mInImum ossIbIo
vnIuo. IIoIInIng yIoIds n roducfIon In fho nvorngo oxocufIon fImo or InsfrucfIon.
ocronsIng fho numbor of cIock cycIos or InsfrucfIon (CII).
Computev AvcLItectuve
TLunguveI Muvugun 64
IIoIInIng Is nn ImIomonfnfIon fochnIquo fhnf oxIoIfs nrnIIoIIsm nmong fho
InsfrucfIons In n soquonfInI InsfrucfIon sfronm. If hns fho subsfnnfInI ndvnnfngo fhnf,
unIIko somo soodu fochnIquos, If Is nof vIsIbIo fo fho rogrnmmor.

TLe BusIcs oI u RISC InstvuctIon Set
!ISC (!oducod InsfrucfIon Sof Comufor) nrchIfocfuro or Iond-sforo
nrchIfocfuro. !ISC nrchIfocfuros nro chnrncforIzod by n fow koy roorfIos, whIch
drnmnfIcnIIy sImIIfy fhoIr ImIomonfnfIon:

AII oornfIons on dnfn nIy fo dnfn In rogIsfors nnd fyIcnIIy chnngo fho onfIro
rogIsfor (32 or 64 bIfs or rogIsfor).
Tho onIy oornfIons fhnf nffocf momory nro Iond nnd sforo oornfIons fhnf movo
dnfn from momory fo n rogIsfor or fo momory from n rogIsfor, rosocfIvoIy. !ond
nnd sforo oornfIons fhnf Iond or sforo Ioss fhnn n fuII rogIsfor (o.g., n byfo, l6-
bIfs, or 32-bIfs) nro offon nvnIInbIo.
Tho InsfrucfIons formnfs nro smnII In numbor wIfh nII InsfrucfIons fyIcnIIy
boIng ono sIzo.

!Iko ofhor !ISC nrchIfocfuros, fho MIIS InsfrucfIon sof rovIdos 32 rogIsfors,
nIfhough rogIsfor 0 nIwnys hns fho vnIuo 0. Mosf !ISC nrchIfocfuros, IIko MIIS, hnvo
fhroo cInssos of InsfrucfIons:

l. AIU InstvuctIons:
Thoso InsfrucfIons fnko oIfhor fwo rogIsfors or n rogIsfor nnd n sIgn-
oxfondod ImmodInfo (cnIIod A!! ImmodInfo InsfrucfIons, fhoy hnvo n l6-bIf
offsof In MIIS), oornfo on fhom, nnd sforo fho rosuIf Info fhIrd rogIsfor. TyIcnI
oornfIons IncIudo ndd (A), subfrncf (S!I), nnd IogIcnI oornfIons (such ns
A or O!), whIch do nof dIfforonfInfo bofwoon 32-bIf nnd 64-bIf vorsIons.
ImmodInfo vorsIons of fhoso InsfrucfIons uso fho snmo mnomonIcs wIfh n suffIx
of I.
Computev AvcLItectuve
TLunguveI Muvugun 65
In MIIS, fhoro nro bofh sIgnod nnd unsIgnod forms of fho nrIfhmofIc
InsfrucfIons; fho unsIgnod forms, whIch do nof gonornfo ovorfIow oxcofIons
nnd fhus nro fho snmo In 32-bIf nnd 64-bIf modohnvo n ! nf fho ond (o.g.
A!, S!I!, A!I).

2. Ioud und stove InstvuctIons:
Thoso InsfrucfIons fnko n rogIsfor sourco, cnIIod fho bnso rogIsfor nnd nn
ImmodInfo fIoId (l6-bIf In MIIS), nnd cnIIod fho offsof, ns oornnd. Tho sum
cnIIod fho effecIite oJJreeeof fho confonfs of fho bnso rogIsfor nnd fho sIgn-
oxfondod offsof Is usod ns n momory nddross.
In fho cnso of n Iond InsfrucfIon, n socond rogIsfor oornnd ncfs ns fho
dosfInnfIon for fho dnfn Iondod from momory. In fho cnso of n sforo, fho socond
rogIsfor oornnd Is fho sourco of fho dnfn fhnf Is sforod Info momory. Tho
InsfrucfIons Iond word (!) nnd sforo word (S) Iond or sforo fho onfIro 64-bIf
rogIsfor confonfs.

3. BvuncLes und Jumps:
Irnnchos nro condIfIonnI frnnsfors of confroI. Thoro nro usunIIy fwo wnys
of socIfyIng fho brnnch condIfIon In !ISC nrchIfocfuros: wIfh n sof of condIfIon
bIfs (somofImos cnIIod n condIfIon codo) or by n IImIfod sof of comnrIsons
bofwoon n nIr of rogIsfors or bofwoon n rogIsfor nnd zoro.
In nII !ISC nrchIfocfuros, fho brnnch dosfInnfIon Is obfnInod by nddIng n
sIgn-oxfondod offsof (l6-bIfs In MIIS) fo fho curronf IC. !ncondIfIonnI jums
nro rovIdod In mnny !ISC nrchIfocfuros.

A SImpIe ImpIementutIon oI u RISC InstvuctIon Set
Ivory InsfrucfIon fnkos nf mosf fIvo cIock cycIos. Ivory InsfrucfIon In fhIs !ISC
subsof cnn bo ImIomonfod In nf mosf fIvo cIock cycIos. Tho fIvo cIock cycIos nro ns
foIIows.


Computev AvcLItectuve
TLunguveI Muvugun 66
1. InstvuctIon IetcL cycIe (II):
Sond fho rogrnm counfor (IC) fo momory nnd fofch fho curronf InsfrucfIon from
momory. !dnfo fho IC fo fho noxf soquonfInI IC by nddIng four (sInco onch
InsfrucfIon Is four byfos) fo fho IC.
2. InstvuctIon decode/vegIstev IetcL cycIe (I):
ocodo fho InsfrucfIon nnd rond fho rogIsfors corrosondIng fo rogIsfor sourco
socIfIors from fho rogIsfor fIIo. o fho oqunIIfy fosf on fho rogIsfors ns fhoy nro rond,
for n ossIbIo brnnch. SIgn oxfond fho offsof fIoId of fho InsfrucfIon In cnso If Is noodod.
Comufo fho ossIbIo brnnch fnrgof nddross by nddIng fho sIgn-oxfondod offsof
fo fho Incromonfod IC. ocodIng Is dono In nrnIIoI wIfh rondIng rogIsfors, whIch Is
ossIbIo bocnuso fho rogIsfor socIfIors nro nf n fIxod IocnfIon In !ISC nrchIfocfuro. ThIs
fochnIquo Is known ns fIxod-fIoId docodIng.
3. ecutIon/eIIectIve uddvess cycIe (X):
Tho A!! oornfos on fho oornnds ronrod In fho rIor cycIo, orformIng ono of
fhroo funcfIons doondIng on fho InsfrucfIon fyo.
Memory reference:
Tho A!! ndds fho bnso rogIsfor nnd fho offsof fo form fho offocfIvo nddross.
Regioter-Regioter ALU inotruction:
Tho A!! orforms fho oornfIon socIfIod by fho A!! ocodo on fho vnIuos rond from
fho rogIsfor fIIo.
Regioter-1mmeJiute ALU inotruction:
Tho A!! orforms fho oornfIon socIfIod by fho A!! ocodo on fho fIrsf vnIuo rond
from fho rogIsfor fIIo nnd fho sIgn-oxfondod ImmodInfo.
4. Memovy uccess (MM):
If fho InsfrucfIon Is n Iond, fhon rond from momory usIng fho offocfIvo nddross
comufod In fho rovIous cycIo. If If Is n sforo, fhon fho dnfn from fho socond rogIsfor
rond from fho rogIsfor fIIo Is wrIffon Info momory usIng fho offocfIvo nddross.
5. WvIte-buck cycIe (WB):
Regioter-Regioter ALU inotruction or LouJ inotruction:
WrIfo fho rosuIf Info fho rogIsfor fIIo, whofhor If comos from fho momory sysfom (for n
Iond) or from fho A!! (for nn A!! InsfrucfIon).
Computev AvcLItectuve
TLunguveI Muvugun 6?


TLe CIussIc IIve-Stuge PIpeIIne Iov A RISC pvocessov
Wo cnn IoIIno fho oxocufIon n now InsfrucfIon on onch cIock cycIo. Inch of fho
cIock cycIos from fho rovIous socfIon bocomos n pipe eIoge. n cycIo In fho IoIIno.
Inch InsfrucfIon fnkos fIvo cIock cycIos fo comIofo, durIng onch cIock cycIo fho
hnrdwnro wIII InIfInfo n now InsfrucfIon nnd wIII bo oxocufIng somo nrf of fho fIvo
dIfforonf InsfrucfIons.

SImpIe RISC pIpeIIne.

IIrsf, wo uso sonrnfo InsfrucfIon nnd dnfn momorIos, whIch wo wouId fyIcnIIy
ImIomonf wIfh sonrnfo InsfrucfIon nnd dnfn cnchos. Tho uso of sonrnfo cnchos
oIImInnfos n confIIcf for n sIngIo momory fhnf wouId nrIso bofwoon InsfrucfIon fofch nnd
dnfn momory nccoss. ofIco fhnf If our IoIInod rocossor hns n cIock cycIo fhnf Is
oqunI fo fhnf of fho unIoIInod vorsIon, fho momory sysfom musf doIIvor fIvo fImos fho
bnndwIdfh. ThIs Incronsod domnnd Is ono cosf of hIghor orformnnco.

Socond, fho rogIsfor fIIo Is usod In fho fwo sfngos: ono for rondIng In I nnd ono
for wrIfIng In WI. Wo nood fo orform fwo ronds nnd ono wrIfo ovory cIock cycIo. To
hnndIo ronds nnd n wrIfo fo fho snmo rogIsfor (nnd for nnofhor ronson, whIch wIII
bocomo obvIous shorfIy), wo orform fho rogIsfor wrIfo In fho fIrsf hnIf of fho cIock cycIo
nnd fho rond In fho socond hnIf.
Computev AvcLItectuve
TLunguveI Muvugun 6B

TLe pIpeIIne cun be tLougLt oI us u sevIes oI dutuputLs sLIIted In tIme.

ThIrd, IIguro doos nof donI wIfh fho IC. To sfnrf n now InsfrucfIon ovory cIock,
wo musf Incromonf nnd sforo fho IC ovory cIock, nnd fhIs musf bo dono. urIng fho II
sfngo In ronrnfIon for fho noxf InsfrucfIon. Ono furfhor robIom Is fhnf n brnnch doos
nof chnngo fho IC unfII fho I sfngo.

AIfhough If Is crIfIcnI fo onsuro fhnf InsfrucfIons In fho IoIIno do nof nffomf
fo uso fho hnrdwnro rosourcos nf fho snmo fImo, wo musf nIso onsuro fhnf InsfrucfIons
In dIfforonf sfngos of fho IoIIno do nof Inforforo wIfh ono nnofhor. ThIs sonrnfIon Is
dono by InfroducIng pipeline regieIere bofwoon succossIvo sfngos of fho IoIIno, so fhnf
nf fho ond of n cIock cycIo nII fho rosuIfs from n gIvon sfngo nro sforod Info n rogIsfor
fhnf Is usod ns fho Inuf fo fho noxf sfngo on fho noxf cIock cycIo.
Computev AvcLItectuve
TLunguveI Muvugun 69
In fho cnso of n IoIInod rocossor, fho IoIIno rogIsfors nIso Iny fho koy roIo
of cnrryIng InformodInfo rosuIfs from ono sfngo fo nnofhor whoro fho sourco nnd
dosfInnfIon mny bo dIrocfIy ndjnconf. If Is somofImos usofuI fo nnmo fho IoIIno
rogIsfors. Tho rogIsfors nro cnIIod I/II, II/!I, !I/IX, IX/MIM, MIM/WI.


A pIpeIIne sLowIng tLe pIpeIIne vegIstevs between successIve pIpeIIne
stuges

BusIc PevIovmunce Issues In PIpeIInIng
IIoIInIng Incronsos fho CI! InsfrucfIon fhroughuffho numbor of
InsfrucfIons comIofod or unIf of fImobuf If doos nof roduco fho oxocufIon fImo of nn
IndIvIdunI InsfrucfIon.
Tho Incronso In InsfrucfIon fhroughuf monns fhnf n rogrnm runs fnsfor nnd
hns Iowor fofnI oxocufIon fImo, ovon fhough no sIngIo InsfrucfIon runs fnsfor!
Computev AvcLItectuve
TLunguveI Muvugun ?0
Tho fncf fhnf fho oxocufIon fImo of onch InsfrucfIon doos nof docronso ufs IImIfs
on fho rncfIcnI dofh of n IoIIno. In nddIfIon fo IImIfnfIons nrIsIng from IoIIno
Infoncy, IImIfs nrIso from ImbnInnco nmong fho Io sfngos nnd from IoIInIng
ovorhond. ImbnInnco nmong fho Io sfngos roducos orformnnco sInco fho cIock cnn
run no fnsfor fhnn fho fImo noodod for fho sIowosf IoIIno sfngo. IIoIIno ovorhond
nrIsos from fho combInnfIon of IoIIno rogIsfor doIny nnd cIock skow.
Tho IoIIno rogIsfors ndd sofu fImo, whIch Is fho fImo fhnf n rogIsfor Inuf
musf bo sfnbIo boforo fho cIock sIgnnI fhnf frIggors n wrIfo occurs, Ius rongnfIon
doIny fo fho cIock cycIo. CIock skow, whIch Is mnxImum doIny bofwoon whon fho cIock
nrrIvos nf nny fwo rogIsfors, nIso confrIbufos fo fho Iowor IImIf on fho cIock cycIo. Onco
fho cIock cycIo Is ns smnII ns fho sum of fho cIock skow nnd Infch ovorhond, no furfhor
IoIInIng Is usofuI, sInco fhoro Is no fImo Ioff In fho cycIo for usofuI work.

Avorngo InsfrucfIon oxocufIon fImo = CIock cycIo Avorngo CII



TLe MuJov HuvdIe oI PIpeIInIngPIpeIIne Huzuvds
HocorJe, whIch rovonfs fho noxf InsfrucfIon In fho InsfrucfIon sfronm from
oxocufIng durIng Ifs dosIgnnfod cIock cycIo. Hnznrds roduco fho orformnnco from fho
IdonI soodu gnInod by IoIInIng. Thoro nro fhroo cInssos of hnznrds:

l. SIrucIurol IocorJe nrIso from rosourco confIIcfs whon fho hnrdwnro cnnnof suorf
nII ossIbIo combInnfIons of InsfrucfIons sImuIfnnoousIy In ovorInod oxocufIon.
2. DoIo IocorJe nrIso whon nn InsfrucfIon doonds on fho rosuIfs of n rovIous
InsfrucfIon In n wny fhnf Is oxosod by fho ovorInIng of InsfrucfIons In fho IoIIno.
3. ConIrol IocorJe nrIso from fho IoIInIng of brnnchos nnd ofhor InsfrucfIons fhnf
chnngo fho IC.
Computev AvcLItectuve
TLunguveI Muvugun ?1
Hnznrds In IoIInos cnn mnko If nocossnry fo eIoll fho IoIIno. AvoIdIng n
hnznrd offon roquIros fhnf somo InsfrucfIons In fho IoIIno bo nIIowod fo rocood whIIo
ofhors nro doInyod.

PevIovmunce oI PIpeIInes wItL StuIIs
Soodu from IoIInIng,


IIoIInIng cnn bo fhoughf of ns docronsIng fho CII or fho cIock cycIo fImo. SInco
If Is frndIfIonnI fo uso fho CII fo comnro IoIInos. Tho IdonI CII on n IoIInod
rocossor Is nImosf nIwnys l. Honco, wo cnn comufo fho IoIInod CII:



If wo Ignoro fho cycIo fImo ovorhond of IoIInIng nnd nssumo fho sfngos nro
orfocfIy bnInncod, fhon fho cycIo fImo of fho fwo rocossors cnn bo oqunI, IondIng fo

Tho unIoIInod CII Is oqunI fo fho dofh of fho IoIIno, IondIng fo

AIfornnfIvoIy, If wo fhInk of IoIInIng ns ImrovIng fho cIock cycIo fImo, fhon wo
cnn nssumo fhnf fho CII of fho unIoIInod rocossor, ns woII ns fhnf of fho IoIInod
rocossor, Is l.
Computev AvcLItectuve
TLunguveI Muvugun ?2
ThIs Ionds fo

In cnsos whoro fho Io sfngos nro orfocfIy bnInncod nnd fhoro Is no ovorhond,
fho cIock cycIo on fho IoIInod rocossor Is smnIIor fhnn fho cIock cycIo of fho
unIoIInod rocossor by n fncfor oqunI fo fho IoIInod dofh:

ThIs Ionds fo fho foIIowIng:

Thus, If fhoro nro no sfnIIs, fho soodu Is oqunI fo fho numbor of IoIIno
sfngos, mnfchIng our InfuIfIon for fho IdonI cnso.

StvuctuvuI Huzuvds
Whon n rocossor Is IoIInod, fho ovorInod oxocufIon of InsfrucfIons roquIros
IoIInIng of funcfIonnI unIfs nnd duIIcnfIon of rosourcos fo nIIow nII ossIbIo
combInnfIons of InsfrucfIons In fho IoIIno. If somo combInnfIon of InsfrucfIons cnnnof
bo nccommodnfod bocnuso of rosourco confIIcfs, fho rocossor Is snId fo hnvo n
eIrucIurol IocorJ.
Tho mosf common Insfnncos of sfrucfurnI hnznrds nrIso whon somo funcfIonnI
unIf Is nof fuIIy IoIInod. Thon n soquonco of InsfrucfIons usIng fhnf unIoIInod unIf
cnnnof rocood nf fho rnfo of ono or cIock cycIo.
Anofhor common wny fhnf sfrucfurnI hnznrds nonr Is whon somo rosourco hns
nof boon duIIcnfod onough fo nIIow nII combInnfIons of InsfrucfIons In fho IoIIno fo
oxocufo.
Computev AvcLItectuve
TLunguveI Muvugun ?3
Ior oxnmIo, n rocossor mny hnvo onIy ono rogIsfor-fIIo wrIfo orf, buf undor
corfnIn cIrcumsfnncos, fho IoIIno mIghf wnnf fo orform fwo wrIfos In n cIock cycIo.
ThIs wIII gonornfo n sfrucfurnI hnznrd. Whon n soquonco of InsfrucfIons oncounfors fhIs
hnznrd, fho IoIIno wIII sfnII ono of fho InsfrucfIons unfII fho roquIrod unIf Is
nvnIInbIo. Such sfnIIs wIII Incronso fho CII from Ifs usunI IdonI vnIuo of l.A sfnII Is
commonIy cnIIod n pipeline IuIIle or jusf IuIIle, sInco If fIonfs fhrough fho IoIIno
fnkIng snco buf cnrryIng no usofuI work.



A pvocessov wItL onIy one memovy povt wIII genevute u conIIIct wLenevev u
memovy veIevence occuvs.
Computev AvcLItectuve
TLunguveI Muvugun ?4

A pIpeIIne stuIIed Iov u stvuctuvuI Luzuvdu Ioud wItL one memovy povt.

utu Huzuvds
A mnjor offocf of IoIInIng Is fo chnngo fho roInfIvo fImIng of InsfrucfIons by
ovorInIng fhoIr oxocufIon. ThIs ovorIn Infroducos dnfn nnd confroI hnznrds. nfn
hnznrds occur whon fho IoIIno chnngos fho ordor of rond/wrIfo nccossos fo oornnds so
fhnf fho ordor dIffors from fho ordor soon by soquonfInIIy oxocufIng InsfrucfIons on nn
unIoIInod rocossor.

ConsIdor fho IoIInod oxocufIon of fhoso InsfrucfIons:
A !l,!2,!3
S!I !4,!l,!5
A !6,!l,!?
O! !8,!l,!9
XO! !l0,!l,!ll

AII fho InsfrucfIons nffor fho A uso fho rosuIf of fho A InsfrucfIon. As
shown In IIguro, fho A InsfrucfIon wrIfos fho vnIuo of !l In fho WI Io sfngo,
buf fho S!I InsfrucfIon ronds fho vnIuo durIng Ifs I sfngo. ThIs robIom Is cnIIod n
JoIo IocorJ.
Tho A InsfrucfIon Is nIso nffocfod by fhIs hnznrd. As wo cnn soo from IIguro,
fho wrIfo of !l doos nof comIofo unfII fho ond of cIock cycIo 5. Thus, fho A
InsfrucfIon fhnf ronds fho rogIsfors durIng cIock cycIo 4 wIII rocoIvo fho wrong rosuIfs.
Computev AvcLItectuve
TLunguveI Muvugun ?5
Tho XO! InsfrucfIon oornfos roorIy, bocnuso Ifs rogIsfor rond occurs In cIock
cycIo 6, nffor fho rogIsfor wrIfo. Tho O! InsfrucfIon nIso oornfos wIfhouf IncurrIng n
hnznrd bocnuso wo orform fho rogIsfor fIIo ronds In fho socond hnIf of fho cycIo nnd fho
wrIfos In fho fIrsf hnIf.

MInImIzIng utu Huzuvd StuIIs By IovwuvdIng
Tho robIom osod In IIguro A.6 cnn bo soIvod wIfh n sImIo hnrdwnro
fochnIquo cnIIod foruorJing (nIso cnIIod I,poeeing nnd somofImos eIorI-circuiIing).
If fho rosuIf cnn bo movod from fho IoIIno rogIsfor whoro fho A sforos If fo
whoro fho S!I noods If, fhon fho nood for n sfnII cnn bo nvoIdod. !sIng fhIs
obsorvnfIon, forwnrdIng works ns foIIows:
l. Tho A!! rosuIf from bofh fho IX/MIM nnd MIM/WI IoIIno rogIsfors Is
nIwnys fod bnck fo fho A!! Inufs.
2. If fho forwnrdIng hnrdwnro dofocfs fhnf fho rovIous A!! oornfIon hns wrIffon
fho rogIsfor corrosondIng fo n sourco for fho curronf A!! oornfIon, confroI
IogIc soIocfs fho forwnrdod rosuIf ns fho A!! Inuf rnfhor fhnn fho vnIuo rond
from fho rogIsfor fIIo.
IorwnrdIng cnn bo gonornIIzod fo IncIudo nssIng n rosuIf dIrocfIy fo fho
funcfIonnI unIf fhnf roquIros If: A rosuIf Is forwnrdod from fho IoIIno rogIsfor
corrosondIng fo fho oufuf of ono unIf fo fho Inuf of nnofhor, rnfhor fhnn jusf from
fho rosuIf of n unIf fo fho Inuf of fho snmo unIf.

Tnko, for oxnmIo, fho foIIowIng soquonco:
A !l,!2,!3
! !4,0(!l)
S l2(!l),!4

To rovonf n sfnII In fhIs soquonco, wo wouId nood fo forwnrd fho vnIuos of fho
A!! oufuf nnd momory unIf oufuf from fho IoIIno rogIsfors fo fho A!! nnd dnfn
momory Inufs. IIguro shows nII fho forwnrdIng nfhs for fhIs oxnmIo.
Computev AvcLItectuve
TLunguveI Muvugun ?6

TLe use oI tLe vesuIt oI tLe A InstvuctIon In tLe net tLvee InstvuctIons cuuses
u Luzuvd, sInce tLe vegIstev Is not wvItten untII uItev tLose InstvuctIons veud It.

A set oI InstvuctIons tLut depend on tLe A vesuIt use IovwuvdIng putLs to uvoId
tLe dutu Luzuvd.
Computev AvcLItectuve
TLunguveI Muvugun ??
utu Huzuvds RequIvIng StuIIs
!nforfunnfoIy, nof nII ofonfInI dnfn hnznrds cnn bo hnndIod by bynssIng.
ConsIdor fho foIIowIng soquonco of InsfrucfIons:
! !l,0(!2)
S!I !4,!l,!5
A !6,!l,!?
O! !8,!l,!9

Tho IoIInod dnfnnfh wIfh fho bynss nfhs for fhIs oxnmIo Is shown.

Stoves vequIve un opevund duvIng MM, und IovwuvdIng oI tLut opevund

Tho ! InsfrucfIon doos nof hnvo fho dnfn unfII fho ond of cIock cycIo 4 (Ifs MIM
cycIo), whIIo fho S!I InsfrucfIon noods fo hnvo fho dnfn by fho bogInnIng of fhnf cIock
cycIo. Tho Iond InsfrucfIon hns n doIny or Infoncy fhnf cnnnof bo oIImInnfod by
forwnrdIng nIono. Insfond, wo nood fo ndd hnrdwnro, cnIIod n pipeline inIerlocl, fo
rosorvo fho corrocf oxocufIon nfforn. In gonornI, n pipeline inIerlocl dofocfs n hnznrd
nnd sfnIIs fho IoIIno unfII fho hnznrd Is cIonrod.
Computev AvcLItectuve
TLunguveI Muvugun ?B
In fhIs cnso, fho InforIock sfnIIs fho IoIIno, bogInnIng wIfh fho InsfrucfIon fhnf
wnnfs fo uso fho dnfn unfII fho sourco InsfrucfIon roducos If. ThIs IoIIno InforIock
Infroducos n sfnII or bubbIo, jusf ns If dId for fho sfrucfurnI hnznrd. Tho CII for fho
sfnIIod InsfrucfIon Incronsos by fho Iongfh of fho sfnII.

TLe Ioud InstvuctIon cun bypuss Its vesuIts to tLe AN und OR InstvuctIons, but
not to tLe SUB, sInce tLut wouId meun IovwuvdIng tLe vesuIt In "negutIve tIme."

In tLe top LuII, we cun see wLy u stuII Is needed: tLe MM cycIe oI tLe Ioud
pvoduces u vuIue tLut Is needed In tLe X cycIe oI tLe SUB, wLIcL occuvs ut tLe
sume tIme.

Computev AvcLItectuve
TLunguveI Muvugun ?9
BvuncL Huzuvds
ConIrol IocorJe cnn cnuso n gronfor orformnnco Ioss for our MIIS IoIIno fhnn
do dnfn hnznrds. Whon n brnnch Is oxocufod, If mny or mny nof chnngo fho IC fo
somofhIng ofhor fhnn Ifs curronf vnIuo Ius 4. !ocnII fhnf If n brnnch chnngos fho IC fo
Ifs fnrgof nddross, If Is n Iolen brnnch; If If fnIIs fhrough, If Is noI Iolen, or unIolen. If
InsfrucfIon i Is n fnkon brnnch, fhon fho IC Is normnIIy nof chnngod unfII fho ond of I,
nffor fho comIofIon of fho nddross cnIcuInfIon nnd comnrIson
IIguro shows fhnf fho sImIosf mofhod of donIIng wIfh brnnchos Is fo rodo fho
fofch of fho InsfrucfIon foIIowIng n brnnch, onco wo dofocf fho brnnch durIng I (whon
InsfrucfIons nro docodod). Tho fIrsf II cycIo Is ossonfInIIy n sfnII, bocnuso If novor
orforms usofuI work. You mny hnvo nofIcod fhnf If fho brnnch Is unfnkon, fhon fho
roofIfIon of fho II sfngo Is unnocossnry sInco fho corrocf InsfrucfIon wns Indood
fofchod. Wo wIII dovoIo sovornI schomos fo fnko ndvnnfngo of fhIs fncf shorfIy.

A bvuncL cuuses u one-cycIe stuII In tLe IIve-stuge pIpeIIne.

ReducIng PIpeIIne BvuncL PenuItIes
Tho soffwnro cnn fry fo mInImIzo fho brnnch onnIfy usIng knowIodgo of fho
hnrdwnro schomo nnd of brnnch bohnvIor. Tho sImIosf schomo fo hnndIo brnnchos Is fo
freece or flueI fho IoIIno, hoIdIng or doIofIng nny InsfrucfIons nffor fho brnnch unfII
fho brnnch dosfInnfIon Is known. Tho nffrncfIvonoss of fhIs soIufIon IIos rImnrIIy In Ifs
sImIIcIfy bofh for hnrdwnro nnd soffwnro.
A hIghor orformnnco, nnd onIy sIIghfIy moro comIox, schomo Is fo fronf ovory
brnnch ns nof fnkon, sImIy nIIowIng fho hnrdwnro fo confInuo ns If fho brnnch woro
nof oxocufod. In fho sImIo fIvo-sfngo IoIIno, fhIs preJicI-noI-Iolen or preJicI-unIolen
schomo Is ImIomonfod by confInuIng fo fofch InsfrucfIons ns If fho brnnch woro n
normnI InsfrucfIon.
Computev AvcLItectuve
TLunguveI Muvugun B0
An nIfornnfIvo schomo Is fo fronf ovory brnnch ns fnkon. As soon ns fho brnnch Is
docodod nnd fho fnrgof nddross Is comufod, wo nssumo fho brnnch fo bo fnkon nnd
bogIn fofchIng nnd oxocufIng nf fho fnrgof. Iocnuso In our fIvo-sfngo IoIIno wo don`f
know fho fnrgof nddross nny onrIIor fhnn wo know fho brnnch oufcomo, fhoro Is no
ndvnnfngo In fhIs nronch for fhIs IoIIno.
In oIfhor n rodIcf-fnkon or rodIcf-nof-fnkon schomo, fho comIIor cnn Imrovo
orformnnco by orgnnIzIng fho codo so fhnf fho mosf froquonf nfh mnfchos fho
hnrdwnro`s choIco.


TLe pvedIct-not-tuken scLeme und tLe pIpeIIne sequence wLen tLe bvuncL Is
untuken (top) und tuken (bottom).

A fourfh schomo In uso In somo rocossors Is cnIIod Jelo,eJ IroncI. ThIs
fochnIquo wns honvIIy usod In onrIy !ISC rocossors nnd works ronsonnbIy woII In fho
fIvo-sfngo IoIIno. In n doInyod brnnch, fho oxocufIon cycIo wIfh n brnnch doIny of ono
Is
IroncI ineIrucIion
eequenIiol eucceeeor1
IroncI IorgeI if Iolen
Tho soquonfInI succossor Is In fho IroncI-Jelo, eloI. ThIs InsfrucfIon Is oxocufod
whofhor or nof fho brnnch Is fnkon.

Computev AvcLItectuve
TLunguveI Muvugun B1

TLe beLuvIov oI u deIuyed bvuncL Is tLe sume wLetLev ov not tLe bvuncL Is
tuken.
Tho IImIfnfIons on doInyod-brnnch schoduIIng nrIso from (l) fho rosfrIcfIons on
fho InsfrucfIons fhnf nro schoduIod Info fho doIny sIofs nnd (2) our nbIIIfy fo rodIcf nf
comIIo fImo whofhor n brnnch Is IIkoIy fo bo fnkon or nof. To Imrovo fho nbIIIfy of fho
comIIor fo fIII brnnch doIny sIofs, mosf rocossors wIfh condIfIonnI brnnchos hnvo
Infroducod n concelling or nullif,ing brnnch.
In n cnncoIIIng brnnch, fho InsfrucfIon IncIudos fho dIrocfIon fhnf fho brnnch wns
rodIcfod. Whon fho brnnch bohnvos ns rodIcfod, fho InsfrucfIon In fho brnnch-doIny
sIof Is sImIy oxocufod ns If wouId normnIIy bo wIfh n doInyod brnnch.
Whon fho brnnch Is IncorrocfIy rodIcfod, fho InsfrucfIon In fho brnnch-doIny sIof
Is sImIy furnod Info n no-o.

PevIovmunce oI BvuncL ScLemes

Whnf Is fho offocfIvo orformnnco of onch of fhoso schomos` Tho offocfIvo IoIIno
soodu wIfh brnnch onnIfIos, nssumIng nn IdonI CII of l, Is

Iocnuso of fho foIIowIng:
IIoIIno sfnII cycIos from brnnchos = Irnnch froquoncy Irnnch onnIfy

Computev AvcLItectuve
TLunguveI Muvugun B2
Wo obfnIn

Tho brnnch froquoncy nnd brnnch onnIfy cnn hnvo n comononf from bofh
uncondIfIonnI nnd condIfIonnI brnnchos. Howovor, fho Inffor domInnfo sInco fhoy nro
moro froquonf.

How Is PIpeIInIng ImpIemented?
A SImpIe ImpIementutIon oI MIPS
Ivory MIIS InsfrucfIon cnn bo ImIomonfod In nf mosf fIvo cIock cycIos. Tho fIvo cIock
cycIos nro ns foIIows.

1. 1notruction fetch cycle (II):
I! <-- Mom|IC];
IC <-- IC + 4;
OperoIion. Sond ouf fho IC nnd fofch fho InsfrucfIon from momory Info fho InsfrucfIon
rogIsfor (I!); Incromonf fho IC by 4 fo nddross fho noxf soquonfInI InsfrucfIon. Tho I!
Is usod fo hoId fho InsfrucfIon fhnf wIII bo noodod on subsoquonf cIock cycIos; IIkowIso
fho rogIsfor IC Is usod fo hoId fho noxf soquonfInI IC.

2. 1notruction JecoJe/regioter fetch cycle (I):
A <-- !ogs|rs];
I <-- !ogs|Irf];
Imm <-- sIgn oxfondod ImmodInfo fIoId of I!;
OperoIion.
ocodo fho InsfrucfIon nnd nccoss fho rogIsfor fIIo fo rond fho rogIsfors (rs nnd rf
nro fho rogIsfor socIfIors). Tho oufufs of fho gonornI-uroso rogIsfors nro rond Info
fwo fomornry rogIsfors (A nnd I) for uso In Infor cIock cycIos.Tho Iowor l6 bIfs of fho
I! nro nIso sIgn-oxfondod nnd sforod Info fho fomornry rogIsfor Imm, for uso In fho
noxf cycIo. ocodIng Is dono In nrnIIoI wIfh rondIng rogIsfors, whIch Is ossIbIo
bocnuso fhoso fIoIds nro nf n fIxod IocnfIon In fho MIIS InsfrucfIon formnf.
Computev AvcLItectuve
TLunguveI Muvugun B3
Iocnuso fho ImmodInfo orfIon of nn InsfrucfIon Is Iocnfod In nn IdonfIcnI Inco
In ovory MIIS formnf, fho sIgn-oxfondod ImmodInfo Is nIso cnIcuInfod durIng fhIs cycIo
In cnso If Is noodod In fho noxf cycIo.

3. Erecution/effectite uJJreoo cycle (X):
Tho A!! oornfos on fho oornnds ronrod In fho rIor cycIo, orformIng ono of four
funcfIons doondIng on fho MIIS InsfrucfIon fyo.

Menor, reference.
A!!Oufuf <-- A + Imm;
OperoIion: Tho A!! ndds fho oornnds fo form fho offocfIvo nddross nnd Incos fho
rosuIf Info fho rogIsfor A!!Oufuf.

IegieIer-IegieIer AIU ineIrucIion.
A!!Oufuf <-- A func I;
OperoIion. Tho A!! orforms fho oornfIon socIfIod by fho funcfIon codo on fho vnIuo
In rogIsfor A nnd on fho vnIuo In rogIsfor I. Tho rosuIf Is Incod In fho fomornry
rogIsfor A!!Oufuf.

IegieIer-1nneJioIe AIU ineIrucIion.
A!!Oufuf <-- A op Imm;
OperoIion. Tho A!! orforms fho oornfIon socIfIod by fho ocodo on fho vnIuo In
rogIsfor A nnd on fho vnIuo In rogIsfor Imm. Tho rosuIf Is Incod In fho fomornry
rogIsfor A!!Oufuf.

BroncI.
A!!Oufuf <-- IC + Imm;
Cond <--(A == 0)
OperoIion.
Tho A!! ndds fho IC fo fho sIgn-oxfondod ImmodInfo vnIuo In Imm fo
comufo fho nddross of fho brnnch fnrgof.
Computev AvcLItectuve
TLunguveI Muvugun B4
!ogIsfor A, whIch hns boon rond In fho rIor cycIo, Is chockod fo doformIno
whofhor fho brnnch Is fnkon. SInco wo nro consIdorIng onIy ono form of brnnch (IIQZ),
fho comnrIson Is ngnInsf 0. Tho Iond-sforo nrchIfocfuro of MIIS monns fhnf offocfIvo
nddross nnd oxocufIon cycIos cnn bo combInod Info n sIngIo cIock cycIo, sInco no
InsfrucfIon noods fo sImuIfnnoousIy cnIcuInfo n dnfn nddross, cnIcuInfo nn InsfrucfIon
fnrgof nddross, nnd orform nn oornfIon on fho dnfn. Tho ofhor Infogor InsfrucfIons
nof IncIudod nbovo nro jums of vnrIous forms, whIch nro sImIInr fo brnnchos.

4. Memory ucceoo/brunch completion cycle (MM):
Tho IC Is udnfod for nII InsfrucfIons: IC <-- IC;

Menor, reference.
!M <-- Mom|A!!Oufuf] or
Mom|A!!Oufuf] <-- I;
OperoIion. Accoss momory If noodod. If InsfrucfIon Is n Iond, dnfn rofurns from momory
nnd Is Incod In fho !M (Iond momory dnfn) rogIsfor; If If Is n sforo, fhon fho dnfn
from fho I rogIsfor Is wrIffon Info momory. In oIfhor cnso fho nddross usod Is fho ono
comufod durIng fho rIor cycIo nnd sforod In fho rogIsfor A!!Oufuf.

BroncI.
If (cond) IC <-- A!!Oufuf
OperoIion. If fho InsfrucfIon brnnchos, fho IC Is roIncod wIfh fho brnnch dosfInnfIon
nddross In fho rogIsfor A!!Oufuf.

5. Write-buck cycle (WB):

IegieIer-IegieIer AIU ineIrucIion.
!ogs|rd] <-- A!!Oufuf;

IegieIer-1nneJioIe AIU ineIrucIion.
!ogs|rf] <-- A!!Oufuf;
Computev AvcLItectuve
TLunguveI Muvugun B5
IooJ ineIrucIion.
!ogs|rf] <-- !M;
OperoIion. WrIfo fho rosuIf Info fho rogIsfor fIIo, whofhor If comos from fho momory
sysfom (whIch Is In !M) or from fho A!! (whIch Is In A!!Oufuf); fho rogIsfor
dosfInnfIon fIoId Is nIso In ono of fwo osIfIons (rd or rf) doondIng on fho offocfIvo
ocodo.IIguro shows how nn InsfrucfIon fIows fhrough fho dnfn nfh. Af fho ond of onch
cIock cycIo, ovory vnIuo comufod durIng fhnf cIock cycIo nnd roquIrod on n Infor cIock
cycIo (whofhor for fhIs InsfrucfIon or fho noxf) Is wrIffon Info n sforngo dovIco, whIch
mny bo momory, n gonornI-uroso rogIsfor, fho IC, or n fomornry rogIsfor (I.o., !M,
Imm, A, I, I!, IC, A!!Oufuf, or Cond).
Tho fomornry rogIsfors hoId vnIuos bofwoon cIock cycIos for ono InsfrucfIon,
whIIo fho ofhor sforngo oIomonfs nro vIsIbIo nrfs of fho sfnfo nnd hoId vnIuos bofwoon
succossIvo InsfrucfIons.

TLe ImpIementutIon oI tLe MIPS dutuputL uIIows evevy InstvuctIon to be
eecuted In Iouv ov IIve cIock cycIes.



Computev AvcLItectuve
TLunguveI Muvugun B6
A BusIc PIpeIIne Iov MIPS
IIguro shows fho MIIS IoIIno wIfh fho nrorInfo rogIsfors, cnIIod pipeline
regieIere or pipeline loIcIee, bofwoon onch IoIIno sfngo. Tho rogIsfors nro InboIod wIfh
fho nnmos of fho sfngos fhoy connocf. IIguro Is drnwn so fhnf connocfIons fhrough fho
IoIIno rogIsfors from ono sfngo fo nnofhor nro cIonr.
AII of fho rogIsfors noodod fo hoId vnIuos fomornrIIy bofwoon cIock cycIos wIfhIn
ono InsfrucfIon nro subsumod Info fhoso IoIIno rogIsfors. Tho fIoIds of fho InsfrucfIon
rogIsfor (I!), whIch Is nrf of fho II/I rogIsfor, nro InboIod whon fhoy nro usod fo
suIy rogIsfor nnmos. Tho IoIIno rogIsfors cnrry bofh dnfn nnd confroI from ono
IoIIno sfngo fo fho noxf.


TLe dutuputL Is pIpeIIned by uddIng u set oI vegIstevs, one between eucL puIv
oI pIpe stuges.

To confroI fhIs sImIo IoIIno wo nood onIy doformIno how fo sof fho confroI for
fho four muIfIIoxors In fho dnfnnfh of IIguro. Tho fwo muIfIIoxors In fho A!! sfngo
nro sof doondIng on fho InsfrucfIon fyo, whIch Is dIcfnfod by fho I! fIoId of fho I/IX
rogIsfor.
Computev AvcLItectuve
TLunguveI Muvugun B?
Tho fo A!! Inuf muIfIIoxor Is sof by whofhor fho InsfrucfIon Is n brnnch or
nof, nnd fho boffom muIfIIoxor Is sof by whofhor fho InsfrucfIon Is n rogIsfor-rogIsfor
A!! oornfIon or nny ofhor fyo of oornfIon. Tho muIfIIoxor In fho II sfngo choosos
whofhor fo uso fho vnIuo of fho Incromonfod IC or fho vnIuo of fho
IX/MIM.A!!Oufuf (fho brnnch fnrgof) fo wrIfo Info fho IC.
ThIs muIfIIoxor Is confroIIod by fho fIoId IX/MIM.cond. Tho fourfh muIfIIoxor
Is confroIIod by whofhor fho InsfrucfIon In fho WI sfngo Is n Iond or n A!! oornfIon.

ImpIementIng tLe ContvoI Iov tLe MIPS PIpeIIne
Tho rocoss of IoffIng nn InsfrucfIon movo from fho InsfrucfIon docodo sfngo (I)
Info fho oxocufIon sfngo (IX) of fhIs IoIIno Is usunIIy cnIIod ineIrucIion ieeue; nn
InsfrucfIon fhnf hns mndo fhIs sfo Is snId fo hnvo ieeueJ. Ior fho MIIS Infogor
IoIIno, nII fho dnfn hnznrds cnn bo chockod durIng fho I hnso of fho IoIIno.
If n dnfn hnznrd oxIsfs, fho InsfrucfIon Is sfnIIod boforo If Is Issuod. !IkowIso, wo
cnn doformIno whnf forwnrdIng wIII bo noodod durIng I nnd sof fho nrorInfo
confroIs fhon. ofocfIng InforIocks onrIy In fho IoIIno roducos fho hnrdwnro
comIoxIfy bocnuso fho hnrdwnro novor hns fo susond nn InsfrucfIon fhnf hns udnfod
fho sfnfo of fho rocossor, unIoss fho onfIro rocossor Is sfnIIod.
AIfornnfIvoIy, wo cnn dofocf fho hnznrd or forwnrdIng nf fho bogInnIng of n cIock
cycIo fhnf usos nn oornnd (IX nnd MIM for fhIs IoIIno). To show fho dIfforoncos In
fhoso fwo nronchos, wo wIII show how fho InforIock for n !AW hnznrd wIfh fho sourco
comIng from n Iond InsfrucfIon (cnIIod n looJ inIerlocl) cnn bo ImIomonfod by n chock
In I, whIIo fho ImIomonfnfIon of forwnrdIng nfhs fo fho A!! Inufs cnn bo dono
durIng IX.IIguro IIsfs fho vnrIofy of cIrcumsfnncos fhnf wo musf hnndIo.
Onco n hnznrd hns boon dofocfod, fho confroI unIf musf Insorf fho IoIIno sfnII
nnd rovonf fho InsfrucfIons In fho II nnd I sfngos from ndvnncIng. IIguro shows fho
comnrIsons nnd ossIbIo forwnrdIng oornfIons whoro fho dosfInnfIon of fho forwnrdod
rosuIf Is nn A!! Inuf for fho InsfrucfIon curronfIy In IX. IIguro shows fho roIovnnf
sogmonfs of fho IoIInod dnfnnfh wIfh fho nddIfIonnI muIfIIoxors nnd connocfIons In
Inco.

Computev AvcLItectuve
TLunguveI Muvugun BB

SItuutIons tLut tLe pIpeIIne Luzuvd detectIon Luvdwuve cun see by compuvIng
tLe destInutIon und souvces oI udJucent InstvuctIons.


TLe IogIc to detect tLe need Iov Ioud IntevIocks duvIng tLe I stuge oI un
InstvuctIon vequIves tLvee compuvIsons.

euIIng wItL BvuncLes In tLe PIpeIIne
In MIIS, fho brnnchos (IIQZ nnd IIZ) roquIro fosfIng n rogIsfor for oqunIIfy
fo zoro or fo nnofhor rogIsfor for oqunIIfy. Thus, If Is ossIbIo fo comIofo fhIs docIsIon
by fho ond of fho I cycIo by movIng fho zoro fosf Info fhnf cycIo. To fnko ndvnnfngo of
nn onrIy docIsIon on whofhor fho brnnch Is fnkon, bofh ICs (fnkon nnd unfnkon) musf
bo comufod onrIy.

Computev AvcLItectuve
TLunguveI Muvugun B9
ComufIng fho brnnch fnrgof nddross durIng I roquIros nn nddIfIonnI nddor
bocnuso fho mnIn A!!, whIch hns boon usod for fhIs funcfIon so fnr, Is nof usnbIo unfII
IX. IIguro shows fho rovIsod IoIInod dnfnnfh.


IovwuvdIng oI dutu to tLe two AIU Inputs (Iov tLe InstvuctIon In X) cun
occuv Ivom tLe AIU vesuIt (In X/MM ov In MM/WB) ov Ivom tLe Ioud vesuIt
In MM/WB.

Computev AvcLItectuve
TLunguveI Muvugun 90

IovwuvdIng oI vesuIts to tLe AIU vequIves tLe uddItIon oI tLvee etvu Inputs
on eucL AIU muItIpIeev und tLe uddItIon oI tLvee putLs to tLe new Inputs.


TLe stuII Ivom bvuncL Luzuvds cun be veduced by movIng tLe zevo test und
bvuncL tuvget cuIcuIutIon Into tLe I pLuse oI tLe pIpeIIne.

Computev AvcLItectuve
TLunguveI Muvugun 91

RevIsed pIpeIIne stvuctuve
In somo rocossors, brnnch hnznrds nro ovon moro oxonsIvo In cIock cycIos fhnn
In our oxnmIo, sInco fho fImo fo ovnIunfo fho brnnch condIfIon nnd comufo fho
dosfInnfIon cnn bo ovon Iongor.

WLut Mukes PIpeIInIng Huvd to ImpIement?
Tho fIrsf nrf, consIdors fho chnIIongos of oxcofIonnI sIfunfIons whoro fho
InsfrucfIon oxocufIon ordor Is chnngod In unoxocfod wnys. In fho socond nrf, wo
dIscuss somo of fho chnIIongos rnIsod by dIfforonf InsfrucfIon sofs.

euIIng wItL ceptIons
IxcofIonnI sIfunfIons nro hnrdor fo hnndIo In n IoIInod CI! bocnuso fho
ovorInIng of InsfrucfIons mnkos If moro dIffIcuIf fo know whofhor nn InsfrucfIon cnn
snfoIy chnngo fho sfnfo of fho CI!. In n IoIInod CI!, nn InsfrucfIon Is oxocufod Ioco
by Ioco nnd Is nof comIofod for sovornI cIock cycIos. !nforfunnfoIy, ofhor InsfrucfIons
In fho IoIIno cnn rnIso oxcofIons fhnf mny forco fho CI! fo nborf fho InsfrucfIons In
fho IoIIno boforo fhoy comIofo.

Types oI ceptIons und RequIvements
Tho formInoIogy usod fo doscrIbo oxcofIonnI sIfunfIons whoro fho normnI
oxocufIon ordor of InsfrucfIon Is chnngod vnrIos nmong CI!s.
Computev AvcLItectuve
TLunguveI Muvugun 92
Tho forms inIerrupI, foulI, nnd excepIion nro usod, fhough nof In n consIsfonf
fnshIon. Wo uso fho form excepIion fo covor nII fhoso mochnnIsms, IncIudIng fho
foIIowIng:
I/O dovIco roquosf
InvokIng nn oornfIng sysfom sorvIco from n usor rogrnm
TrncIng InsfrucfIon oxocufIon
IronkoInf (rogrnmmor-roquosfod Inforruf)
Infogor nrIfhmofIc ovorfIow
II nrIfhmofIc nnomnIy
Ingo fnuIf (nof In mnIn momory)
MIsnIIgnod momory nccossos (If nIIgnmonf Is roquIrod)
Momory-rofocfIon vIoInfIon
!sIng nn undofInod or unImIomonfod InsfrucfIon
Hnrdwnro mnIfuncfIons
Iowor fnIIuro

Tho roquIromonfs on oxcofIons cnn bo chnrncforIzod on fIvo somIIndoondonf nxos:
l. Synchronouo terouo uoynchronouoIf fho ovonf occurs nf fho snmo Inco ovory
fImo fho rogrnm Is oxocufod wIfh fho snmo dnfn nnd momory nIIocnfIon, fho ovonf Is
e,ncIronoue. WIfh fho oxcofIon of hnrdwnro mnIfuncfIons, oe,ncIronoue ovonfs nro
cnusod by dovIcos oxfornnI fo fho CI! nnd momory. Asynchronous ovonfs usunIIy cnn
bo hnndIod nffor fho comIofIon of fho curronf InsfrucfIon, whIch mnkos fhom onsIor fo
hnndIo.
2. Uoer requeoteJ terouo coerceJIf fho usor fnsk dIrocfIy nsks for If, If Is n ueer
requeeI ovonf. In somo sonso, usor-roquosfod oxcofIons nro nof ronIIy oxcofIons, sInco
fhoy nro rodIcfnbIo. Thoy nro fronfod ns oxcofIons, howovor, bocnuso fho snmo
mochnnIsms fhnf nro usod fo snvo nnd rosforo fho sfnfo nro usod for fhoso usor-
roquosfod ovonfs. Iocnuso fho onIy funcfIon of nn InsfrucfIon fhnf frIggors fhIs
oxcofIon Is fo cnuso fho oxcofIon, usor-roquosfod oxcofIons cnn nIwnys bo hnndIod
nffor fho InsfrucfIon hns comIofod.

Computev AvcLItectuve
TLunguveI Muvugun 93

CoerceJ oxcofIons nro cnusod by somo hnrdwnro ovonf fhnf Is nof undor fho
confroI of fho usor rogrnm. Coorcod oxcofIons nro hnrdor fo ImIomonf bocnuso fhoy
nro nof rodIcfnbIo.
3. Uoer muokuble terouo uoer nonmuokubleIf nn ovonf cnn bo mnskod or dIsnbIod
by n usor fnsk, If Is ueer noeloIle. ThIs mnsk sImIy confroIs whofhor fho hnrdwnro
rosonds fo fho oxcofIon or nof.
4. Within terouo betueen inotructionoThIs cInssIfIcnfIon doonds on whofhor fho
ovonf rovonfs InsfrucfIon comIofIon by occurrIng In fho mIddIo of oxocufIon no
mnffor how shorfor whofhor If Is rocognIzod IeIueen InsfrucfIons. IxcofIons fhnf
occur uiIIin InsfrucfIons nro usunIIy synchronous, sInco fho InsfrucfIon frIggors fho
oxcofIon. If`s hnrdor fo ImIomonf oxcofIons fhnf occur wIfhIn InsfrucfIons fhnn fhoso
bofwoon InsfrucfIons, sInco fho InsfrucfIon musf bo sfood nnd rosfnrfod.
Asynchronous oxcofIons fhnf occur wIfhIn InsfrucfIons nrIso from cnfnsfrohIc
sIfunfIons (o.g., hnrdwnro mnIfuncfIon) nnd nIwnys cnuso rogrnm formInnfIon.
5. Reoume terouo terminuteIf fho rogrnm`s oxocufIon nIwnys sfos nffor fho
Inforruf, If Is n IerninoIing ovonf. If fho rogrnm`s oxocufIon confInuos nffor fho
Inforruf, If Is n reeuning ovonf. If Is onsIor fo ImIomonf oxcofIons fhnf formInnfo
oxocufIon, sInco fho CI! nood nof bo nbIo fo rosfnrf oxocufIon of fho snmo rogrnm
nffor hnndIIng fho oxcofIon.
If n IoIIno rovIdos fho nbIIIfy for fho rocossor fo hnndIo fho oxcofIon, snvo
fho sfnfo, nnd rosfnrf wIfhouf nffocfIng fho oxocufIon of fho rogrnm, fho IoIIno or
rocossor Is snId fo bo reeIorIoIle.

StoppIng und RestuvtIng ecutIon
As In unIoIInod ImIomonfnfIons, fho mosf dIffIcuIf oxcofIons hnvo fwo roorfIos:
(l) Thoy occur wIfhIn InsfrucfIons (fhnf Is, In fho mIddIo of fho InsfrucfIon oxocufIon
corrosondIng fo IX or MIM Io sfngos), nnd
(2) Thoy musf bo rosfnrfnbIo.

Computev AvcLItectuve
TLunguveI Muvugun 94
Whon nn oxcofIon occurs, fho IoIIno confroI cnn fnko fho foIIowIng sfos fo snvo fho
IoIIno sfnfo snfoIy:
l. Iorco n frn InsfrucfIon Info fho IoIIno on fho noxf II.
2. !nfII fho frn Is fnkon, furn off nII wrIfos for fho fnuIfIng InsfrucfIon nnd for nII
InsfrucfIons fhnf foIIow In fho IoIIno; fhIs cnn bo dono by IncIng zoros Info fho
IoIIno Infchos of nII InsfrucfIons In fho IoIIno, sfnrfIng wIfh fho InsfrucfIon
fhnf gonornfos fho oxcofIon, buf nof fhoso fhnf rocodo fhnf InsfrucfIon. ThIs
rovonfs nny sfnfo chnngos for InsfrucfIons fhnf wIII nof bo comIofod boforo fho
oxcofIon Is hnndIod.
3. Affor fho oxcofIon-hnndIIng roufIno In fho oornfIng sysfom rocoIvos confroI, If
ImmodInfoIy snvos fho IC of fho fnuIfIng InsfrucfIon. ThIs vnIuo wIII bo usod fo
rofurn from fho oxcofIon Infor. Whon wo uso doInyod brnnchos, ns monfIonod In
fho Insf socfIon, If Is no Iongor ossIbIo fo ro-cronfo fho sfnfo of fho rocossor
wIfh n sIngIo IC bocnuso fho InsfrucfIons In fho IoIIno mny nof bo soquonfInIIy
roInfod. So wo nood fo snvo nnd rosforo ns mnny ICs ns fho Iongfh of fho brnnch
doIny Ius ono.

If fho IoIIno cnn bo sfood so fhnf fho InsfrucfIons jusf boforo fho fnuIfIng
InsfrucfIon nro comIofod nnd fhoso nffor If cnn bo rosfnrfod from scrnfch, fho IoIIno
Is snId fo hnvo preciee excepIione.

ceptIons In MIPS
IIguro shows fho MIIS IoIIno sfngos nnd whIch robIom oxcofIons mIghf
occur In onch sfngo. WIfh IoIInIng, muIfIIo oxcofIons mny occur In fho snmo cIock
cycIo bocnuso fhoro nro muIfIIo InsfrucfIons In oxocufIon. Ior oxnmIo, consIdor fhIs
InsfrucfIon soquonco:

ThIs nIr of InsfrucfIons cnn cnuso n dnfn ngo fnuIf nnd nn nrIfhmofIc oxcofIon
nf fho snmo fImo, sInco fho ! Is In fho MIM sfngo whIIo fho A Is In fho IX sfngo.
Computev AvcLItectuve
TLunguveI Muvugun 95

ceptIons tLut muy occuv In tLe MIPS pIpeIIne. ceptIons vuIsed Ivom
InstvuctIon ov dutu-memovy uccess uccount Iov sI out oI eIgLt cuses.

InstvuctIon Set CompIIcutIons
o MIIS InsfrucfIon hns moro fhnn ono rosuIf, nnd our MIIS IoIIno wrIfos
fhnf rosuIf onIy nf fho ond of nn InsfrucfIon`s oxocufIon. Whon nn InsfrucfIon Is
gunrnnfood fo comIofo If Is cnIIod conniIIeJ. In fho MIIS Infogor IoIIno, nII
InsfrucfIons nro commIffod whon fhoy ronch fho ond of fho MIM sfngo (or bogInnIng of
WI) nnd no InsfrucfIon udnfos fho sfnfo boforo fhnf sfngo.
A roInfod sourco of dIffIcuIfIos nrIsos from InsfrucfIons fhnf udnfo momory sfnfo
durIng oxocufIon, such ns fho sfrIng coy oornfIons on fho VAX or IIM 360. To mnko If
ossIbIo fo Inforruf nnd rosfnrf fhoso InsfrucfIons, fho InsfrucfIons nro dofInod fo uso
fho gonornI-uroso rogIsfors ns workIng rogIsfors
A dIfforonf sof of dIffIcuIfIos nrIsos from odd bIfs of sfnfo fhnf mny cronfo
nddIfIonnI IoIIno hnznrds or mny roquIro oxfrn hnrdwnro fo snvo nnd rosforo.
CondIfIon codos nro n good oxnmIo of fhIs.

2.2 INSTRUCTION-IVI PARAIIIISM
Concepts und CLuIIenges
InsfrucfIon-IovoI nrnIIoIIsm (I!I) Is fho ofonfInI ovorIn fho oxocufIon of
InsfrucfIons usIng IoIIno concof fo Imrovo orformnnco of fho sysfom. Tho vnrIous
fochnIquos fhnf nro usod fo Incronso nmounf of nrnIIoIIsm nro roducos fho Imncf of
dnfn nnd confroI hnznrds nnd Incronsos rocossor nbIIIfy fo oxIoIf nrnIIoIIsm

Computev AvcLItectuve
TLunguveI Muvugun 96
Thoro nro fwo nronchos fo oxIoIfIng I!I.
l. SfnfIc TochnIquo Soffwnro oondonf
2. ynnmIc TochnIquo Hnrdwnro oondonf
Tho sfnfIc fochnIquo Is comIIor-InfonsIvo nronch, whIch hnvo brondor ndofIon
In fho omboddod mnrkof fhnn fho doskfo or sorvor mnrkofs, fho now IA-64
nrchIfocfuro nnd InfoI`s IfnnIum, uso fhIs moro sfnfIc nronch.
Tho dynnmIc fochnIquo Is hnrdwnro InfonsIvo nronch, whIch domInnfo fho
doskfo nnd sorvor mnrkofs nnd nro usod In n wIdo rnngo of rocossors, IncIudIng: fho
IonfIum III nnd 4, fho AIfhon, fho MIIS !l0000/l2000, fho Sun uIfrnSIA!C III, fho
Iowor-IC 603, C3, nnd C4, nnd fho AIhn 2l264.

TLe muJov tecLnIques togetLev wItL tLe component oI tLe CPI equutIon tLut
tLe tecLnIque uIIects.
Tho sImIosf nnd mosf common wny fo Incronso fho nmounf of nrnIIoIIsm Is
Ioo-IovoI nrnIIoIIsm. Horo Is n sImIo oxnmIo of n Ioo, whIch ndds fwo l000-oIomonf
nrrnys, fhnf Is comIofoIy nrnIIoI:

Iov (I=l;I<=l000; I=I+l)
x|I] = x|I] + y|I];

Computev AvcLItectuve
TLunguveI Muvugun 9?
Ivory IfornfIon of fho Ioo cnn ovorIn wIfh nny ofhor IfornfIon, nIfhough wIfhIn
onch Ioo IfornfIon fhoro Is IIffIo or no oorfunIfy for ovorIn. Thoro nro n numbor of
fochnIquos for convorfIng such Ioo-IovoI nrnIIoIIsm Info InsfrucfIon-IovoI nrnIIoIIsm
nro bnsIcnIIy work by unroIIIng fho Ioo oIfhor sfnfIcnIIy by fho comIIor or dynnmIcnIIy
by fho hnrdwnro. An Imorfnnf nIfornnfIvo mofhod for oxIoIfIng Ioo-IovoI nrnIIoIIsm
Is fho uso of vocfor InsfrucfIons.

PIpeIIne CPI:
CII (CycIos or InsfrucfIon) for n IoIInod rocossor Is fho sum of fho bnso CII
nnd nII confrIbufIons from sfnIIs:
PIpeIIne CPI = IdonI IoIIno CII + SfrucfurnI sfnIIs + nfn hnznrd sfnIIs + ConfroI
sfnIIs
Tho IdonI IoIIno CII Is n monsuro of fho mnxImum orformnnco nffnInnbIo by
fho ImIomonfnfIon. Iy roducIng onch of fho forms of fho rIghf-hnnd sIdo, wo mInImIzo
fho ovornII IoIIno CII nnd fhus Incronso fho IIC (InsfrucfIons or CIock).

utu ependence und Huzuvds:
To oxIoIf InsfrucfIon-IovoI nrnIIoIIsm, doformIno whIch InsfrucfIons cnn bo
oxocufod In nrnIIoI. If fwo InsfrucfIons nro nrnIIoI, fhoy cnn oxocufo sImuIfnnoousIy In
n IoIIno wIfhouf cnusIng nny sfnIIs. If fwo InsfrucfIons nro doondonf fhoy nro nof
nrnIIoI nnd musf bo oxocufod In ordor.
Thoro nro fhroo dIfforonf fyos of doondoncos: dnfn doondoncos (nIso cnIIod
fruo dnfn doondoncos), nnmo doondoncos, nnd confroI doondoncos.
utu ependences:
An InsfrucfIon j Is dnfn doondonf on InsfrucfIon I If oIfhor of fho foIIowIng hoIds:
InsfrucfIon I roducos n rosuIf fhnf mny bo usod by InsfrucfIon j, or
InsfrucfIon j Is dnfn doondonf on InsfrucfIon k, nnd InsfrucfIon k Is dnfn
doondonf on InsfrucfIon I.
Computev AvcLItectuve
TLunguveI Muvugun 9B
Tho socond condIfIon sImIy sfnfos fhnf ono InsfrucfIon Is doondonf on nnofhor
If fhoro oxIsfs n chnIn of doondoncos of fho fIrsf fyo bofwoon fho fwo InsfrucfIons.
ThIs doondonco chnIn cnn bo ns Iong ns fho onfIro rogrnm.
Ior oxnmIo, consIdor fho foIIowIng codo soquonco fhnf Incromonfs n vocfor of
vnIuos In momory (sfnrfIng nf 0(!l) nnd wIfh fho Insf oIomonf nf 8(!2)) by n scnInr In
rogIsfor I2:
!oo: !. I0,0(!l) ; I0=nrrny oIomonf
A. I4,I0,I2 ; ndd scnInr In I2
S. I4,0(!l) ; sforo rosuIf
A!I !l,!l,#-8 ; docromonf oInfor 8 byfos
II !l,!2,!OOI ; brnnch !l!=zoro

Tho dnfn doondoncos In fhIs codo soquonco InvoIvo bofh fIonfIng oInf dnfn:
!oo: !. I0,0(!l) ;I0=nrrny oIomonf
A. I4,I0,I2 ;ndd scnInr In I2
S. I4,0(!l) ;sforo rosuIf

nnd Infogor dnfn:
AI! !l,!l,-8 ;docromonf oInfor
;8 byfos (or W)
II !l,!2,!oo ; brnnch !l!=zoro
Iofh of fho nbovo doondonf soquoncos, ns shown by fho nrrows, wIfh onch
InsfrucfIon doondIng on fho rovIous ono. Tho nrrows horo nnd In foIIowIng oxnmIos
show fho ordor fhnf musf bo rosorvod for corrocf oxocufIon. Tho nrrow oInfs from nn
InsfrucfIon fhnf musf rocodo fho InsfrucfIon fhnf fho nrrowhond oInfs fo.
If fwo InsfrucfIons nro dnfn doondonf fhoy cnnnof oxocufo sImuIfnnoousIy or bo
comIofoIy ovorInod. Tho doondonco ImIIos fhnf fhoro wouId bo n chnIn of ono or
moro dnfn hnznrds bofwoon fho fwo InsfrucfIons. IxocufIng fho InsfrucfIons
sImuIfnnoousIy wIII cnuso n rocossor wIfh IoIIno InforIocks fo dofocf n hnznrd nnd
sfnII, fhoroby roducIng or oIImInnfIng fho ovorIn.
Computev AvcLItectuve
TLunguveI Muvugun 99
oondoncos nro n roorfy of rogrnms. Whofhor n gIvon doondonco rosuIfs In
nn ncfunI hnznrd boIng dofocfod nnd whofhor fhnf hnznrd ncfunIIy cnusos n sfnII nro
roorfIos of fho IoIIno orgnnIznfIon. ThIs dIfforonco Is crIfIcnI fo undorsfnndIng how
InsfrucfIon-IovoI nrnIIoIIsm cnn bo oxIoIfod.
Tho rosonco of fho doondonco IndIcnfos fho ofonfInI for n hnznrd, buf fho
ncfunI hnznrd nnd fho Iongfh of nny sfnII Is n roorfy of fho IoIIno. Tho Imorfnnco
of fho dnfn doondoncos Is fhnf doondonco (l) IndIcnfos fho ossIbIIIfy of n hnznrd, (2)
doformInos fho ordor In whIch rosuIfs musf bo cnIcuInfod, nnd (3) sofs nn uor bound
on how much nrnIIoIIsm cnn ossIbIy bo oxIoIfod.

Nume ependences
Tho nnmo doondonco occurs whon fwo InsfrucfIons uso fho snmo rogIsfor or
momory IocnfIon, cnIIod n nnmo, buf fhoro Is no fIow of dnfn bofwoon fho InsfrucfIons
nssocInfod wIfh fhnf nnmo.
Thoro nro fwo fyos of nnmo doondoncos bofwoon nn InsfrucfIon I fhnf rocodos
InsfrucfIon j In rogrnm ordor:

An nnfIdoondonco bofwoon InsfrucfIon I nnd InsfrucfIon j occurs whon
InsfrucfIon j wrIfos n rogIsfor or momory IocnfIon fhnf InsfrucfIon I ronds.
Tho orIgInnI ordorIng musf bo rosorvod fo onsuro fhnf I ronds fho corrocf
vnIuo.
An oufuf doondonco occurs whon InsfrucfIon I nnd InsfrucfIon j wrIfo fho
snmo rogIsfor or momory IocnfIon. Tho ordorIng bofwoon fho InsfrucfIons
musf bo rosorvod fo onsuro fhnf fho vnIuo fInnIIy wrIffon corrosonds fo
InsfrucfIon j.

Iofh nnfI-doondoncos nnd oufuf doondoncos nro nnmo doondoncos, ns
oosod fo fruo dnfn doondoncos, sInco fhoro Is no vnIuo boIng frnnsmIffod bofwoon
fho InsfrucfIons.
Computev AvcLItectuve
TLunguveI Muvugun 100
SInco n nnmo doondonco Is nof n fruo doondonco, InsfrucfIons InvoIvod In n
nnmo doondonco cnn oxocufo sImuIfnnoousIy or bo roordorod, If fho nnmo (rogIsfor
numbor or momory IocnfIon) usod In fho InsfrucfIons Is chnngod so fho InsfrucfIons do
nof confIIcf.
ThIs ronnmIng cnn bo moro onsIIy dono for rogIsfor oornnds, whoro If Is cnIIod
rogIsfor ronnmIng. !ogIsfor ronnmIng cnn bo dono oIfhor sfnfIcnIIy by n comIIor or
dynnmIcnIIy by fho hnrdwnro. Ioforo doscrIbIng doondoncos nrIsIng from brnnchos,
Iof`s oxnmIno fho roInfIonshI bofwoon doondoncos nnd IoIIno dnfn hnznrds.

ContvoI ependences:
A confroI doondonco doformInos fho ordorIng of nn InsfrucfIon, I, wIfh rosocf fo
n brnnch InsfrucfIon so fhnf fho InsfrucfIon I Is oxocufod In corrocf rogrnm ordor.
Ivory InsfrucfIon, oxcof for fhoso In fho fIrsf bnsIc bIock of fho rogrnm, Is confroI
doondonf on somo sof of brnnchos, nnd, In gonornI, fhoso confroI doondoncos musf bo
rosorvod fo rosorvo rogrnm ordor. Ono of fho sImIosf oxnmIos of n confroI
doondonco Is fho doondonco of fho sfnfomonfs In fho fhon nrf of nn If sfnfomonf on
fho brnnch. Ior oxnmIo, In fho codo sogmonf:
II p1 { Sl;
};
II 2 { S2;
}
Sl Is confroI doondonf on l, nnd S2Is confroI doondonf on 2 buf nof on l. In
gonornI, fhoro nro fwo consfrnInfs Imosod by confroI doondoncos:
An InsfrucfIon fhnf Is confroI doondonf on n brnnch cnnnof bo movod boforo
fho brnnch so fhnf Ifs oxocufIon Is no Iongor confroIIod by fho brnnch. Ior
oxnmIo, wo cnnnof fnko nn InsfrucfIon from fho fhon-orfIon of nn If-
sfnfomonf nnd movo If boforo fho If-sfnfomonf.
An InsfrucfIon fhnf Is nof confroI doondonf on n brnnch cnnnof bo movod
nffor fho brnnch so fhnf Ifs oxocufIon Is confroIIod by fho brnnch. Ior
Computev AvcLItectuve
TLunguveI Muvugun 101
oxnmIo, wo cnnnof fnko n sfnfomonf boforo fho If-sfnfomonf nnd movo If Info
fho fhon-orfIon.
ConfroI doondonco Is rosorvod by fwo roorfIos In n sImIo IoIIno, IIrsf,
InsfrucfIons oxocufo In rogrnm ordor. ThIs ordorIng onsuros fhnf nn InsfrucfIon fhnf
occurs boforo n brnnch Is oxocufod boforo fho brnnch. Socond, fho dofocfIon of confroI or
brnnch hnznrds onsuros fhnf nn InsfrucfIon fhnf Is confroI doondonf on n brnnch Is nof
oxocufod unfII fho brnnch dIrocfIon Is known.

utu Huzuvds
A hnznrd Is cronfod whonovor fhoro Is doondonco bofwoon InsfrucfIons, nnd
fhoy nro cIoso onough fhnf fho ovorIn cnusod by IoIInIng, or ofhor roordorIng of
InsfrucfIons, wouId chnngo fho ordor of nccoss fo fho oornnd InvoIvod In fho
doondonco. Iocnuso of fho doondonco, rosorvo ordor fhnf fho InsfrucfIons wouId
oxocufo In, If oxocufod soquonfInIIy ono nf n fImo ns doformInod by fho orIgInnI sourco
rogrnm.
Tho gonI of bofh our soffwnro nnd hnrdwnro fochnIquos Is fo oxIoIf nrnIIoIIsm
by rosorvIng rogrnm ordor onIy whoro If nffocfs fho oufcomo of fho rogrnm.
ofocfIng nnd nvoIdIng hnznrds onsuros fhnf nocossnry rogrnm ordor Is
rosorvod.nfn hnznrds mny bo cInssIfIod ns ono of fhroo fyos, doondIng on fho ordor
of rond nnd wrIfo nccossos In fho InsfrucfIons. ConsIdor fwo InsfrucfIons I nnd j, wIfh I
occurrIng boforo j In rogrnm ordor. Tho ossIbIo dnfn hnznrds nro

RAW (veud uItev wvIte) j frIos fo rond n sourco boforo I wrIfos If, so j IncorrocfIy
gofs fho oId vnIuo. ThIs hnznrd Is fho mosf common fyo nnd corrosonds fo n fruo dnfn
doondonco. Irogrnm ordor musf bo rosorvod fo onsuro fhnf j rocoIvos fho vnIuo from
I. In fho sImIo common fIvo-sfngo sfnfIc IoIIno n Iond InsfrucfIon foIIowod by nn
Infogor A!! InsfrucfIon fhnf dIrocfIy usos fho Iond rosuIf wIII Iond fo n !AW hnznrd.
WAW (wvIte uItev wvIte) j frIos fo wrIfo nn oornnd boforo If Is wrIffon by I. Tho
wrIfos ond u boIng orformod In fho wrong ordor, IonvIng fho vnIuo wrIffon by I rnfhor
fhnn fho vnIuo wrIffon by j In fho dosfInnfIon. ThIs hnznrd corrosonds fo oufuf
doondonco.
Computev AvcLItectuve
TLunguveI Muvugun 102
WAW hnznrds nro rosonf onIy In IoIInos fhnf wrIfo In moro fhnn ono Io
sfngo or nIIow nn InsfrucfIon fo rocood ovon whon n rovIous InsfrucfIon Is sfnIIod. Tho
cInssIc fIvo-sfngo Infogor IoIIno wrIfos n rogIsfor onIy In fho WI sfngo nnd nvoIds fhIs
cInss of hnznrds.
WAR (wvIte uItev veud) j frIos fo wrIfo n dosfInnfIon boforo If Is rond by I, so I
IncorrocfIy gofs fho now vnIuo. ThIs hnznrd nrIsos from nn nnfIdoondonco. WA!
hnznrds cnnnof occur In mosf sfnfIc Issuo IoIInos ovon dooor IoIInos or fIonfIng
oInf IoIInos bocnuso nII ronds nro onrIy (In I) nnd nII wrIfos nro Info (In WI). A
WA! hnznrd occurs oIfhor whon fhoro nro somo InsfrucfIons fhnf wrIfo rosuIfs onrIy In
fho InsfrucfIon IoIIno, nnd ofhor InsfrucfIons fhnf rond n sourco Info In fho IoIIno or
whon InsfrucfIons nro roordorod.
ConfroI doondonco Is nof fho crIfIcnI roorfy fhnf musf bo rosorvod. Insfond,
fho fwo roorfIos crIfIcnI fo rogrnm corrocfnossnnd normnIIy rosorvod by
mnInfnInIng bofh dnfn nnd confroI doondonconro fho excepIion IeIotior nnd fho JoIo
flou. Tho roorfy of whofhor n vnIuo wIII bo usod by nn ucomIng InsfrucfIon Is cnIIod
liteneee. ThIs fyo of codo schoduIIng Is somofImos cnIIod epeculoIion, sInco fho
comIIor Is boffIng on fho brnnch oufcomo; In fhIs cnso, fho bof Is fhnf fho brnnch Is
usunIIy nof fnkon.

2.3 OVRCOMING ATA HAZARS WITH YNAMIC SCHUIING
Tho ynnmIc SchoduIIng Is usod hnndIo somo cnsos whon doondoncos nro
unknown nf n comIIo fImo. In whIch fho hnrdwnro ronrrnngos fho InsfrucfIon
oxocufIon fo roduco fho sfnIIs whIIo mnInfnInIng dnfn fIow nnd oxcofIon bohnvIor. If
nIso nIIows codo fhnf wns comIIod wIfh ono IoIIno In mInd fo run offIcIonfIy on n
dIfforonf IoIIno. AIfhough n dynnmIcnIIy schoduIod rocossor cnnnof chnngo fho dnfn
fIow, If frIos fo nvoId sfnIIIng whon doondoncos, whIch couId gonornfo hnznrds, nro
rosonf.



Computev AvcLItectuve
TLunguveI Muvugun 103
ynumIc ScLeduIIng: TLe Ideu
A mnjor IImIfnfIon of fho sImIo IoIInIng fochnIquos Is fhnf fhoy nII uso In-
ordor InsfrucfIon Issuo nnd oxocufIon: InsfrucfIons nro Issuod In rogrnm ordor nnd If
nn InsfrucfIon Is sfnIIod In fho IoIIno, no Infor InsfrucfIons cnn rocood. Thus, If fhoro
Is doondonco bofwoon fwo cIosoIy sncod InsfrucfIons In fho IoIIno, fhIs wIII Iond fo n
hnznrd nnd n sfnII. If fhoro nro muIfIIo funcfIonnI unIfs, fhoso unIfs couId IIo IdIo. If
InsfrucfIon j doonds on n Iong-runnIng InsfrucfIon i, curronfIy In oxocufIon In fho
IoIIno, fhon nII InsfrucfIons nffor j musf bo sfnIIod unfII i Is fInIshod nnd j cnn
oxocufo.

Ior oxnmIo, consIdor fhIs codo:
IV. I0,I2,I4
A. Il0,I0,I8
S!I. Il2,I8,Il4

Tho S!I. InsfrucfIon cnnnof oxocufo bocnuso fho doondonco of A. on
IV. cnusos fho IoIIno fo sfnII; yof S!I. Is nof dnfn doondonf on nnyfhIng In fho
IoIIno. ThIs hnznrd cronfos n orformnnco IImIfnfIon fhnf cnn bo oIImInnfod by nof
roquIrIng InsfrucfIons fo oxocufo In rogrnm ordor.
In fho cInssIc fIvo-sfngo IoIIno bofh sfrucfurnI nnd dnfn hnznrds couId bo
chockod durIng InsfrucfIon docodo (I): Whon nn InsfrucfIon couId oxocufo wIfhouf
hnznrds, If wns Issuod from I knowIng fhnf nII dnfn hnznrds hnd boon rosoIvod.
To nIIow us fo bogIn oxocufIng fho S!I. In fho nbovo oxnmIo, wo musf
sonrnfo fho Issuo rocoss Info fwo nrfs: chockIng for nny sfrucfurnI hnznrds nnd
wnIfIng for fho nbsonco of n dnfn hnznrd. Wo cnn sfIII chock for sfrucfurnI hnznrds whon
wo Issuo fho InsfrucfIon; fhus, wo sfIII uso In-ordor InsfrucfIon Issuo (I.o., InsfrucfIons
Issuo In rogrnm ordor), buf wo wnnf nn InsfrucfIon fo bogIn oxocufIon ns soon ns Ifs
dnfn oornnd Is nvnIInbIo. Thus, fhIs IoIIno doos ouI-of-orJer execuIion, whIch ImIIos
ouI-of-orJer conpleIion.
Computev AvcLItectuve
TLunguveI Muvugun 104
Ouf-of-ordor oxocufIon Infroducos fho ossIbIIIfy of WA! nnd WAW hnznrds,
whIch do nof oxIsf In fho fIvo-sfngo Infogor IoIIno nnd Ifs IogIcnI oxfonsIon fo nn In-
ordor fIonfIng-oInf IoIIno.
Ouf-of-ordor comIofIon nIso cronfos mnjor comIIcnfIons In hnndIIng oxcofIons.
ynnmIc schoduIIng wIfh ouf-of-ordor comIofIon musf rosorvo oxcofIon bohnvIor In
fho sonso fhnf exocIl, fhoso oxcofIons fhnf wouId nrIso If fho rogrnm woro oxocufod In
sfrIcf rogrnm ordor ocIuoll, do nrIso. ImrocIso oxcofIons cnn occur bocnuso of fwo
ossIbIIIfIos:

l. Tho IoIIno mny hnvo nIrondy conpleIeJ InsfrucfIons fhnf nro loIer In rogrnm
ordor fhnn fho InsfrucfIon cnusIng fho oxcofIon, nnd
2. Tho IoIIno mny hnvo noI ,eI conpleIeJ somo InsfrucfIons fhnf nro eorlier In
rogrnm ordor fhnn fho InsfrucfIon cnusIng fho oxcofIon.

To nIIow ouf-of-ordor oxocufIon, wo ossonfInIIy sIIf fho I Io sfngo of our
sImIo fIvo-sfngo IoIIno Info fwo sfngos:
l 1eeueocodo InsfrucfIons, chock for sfrucfurnI hnznrds.
2 IeoJ operonJeWnIf unfII no dnfn hnznrds, fhon rond oornnds.

In n dynnmIcnIIy schoduIod IoIIno, nII InsfrucfIons nss fhrough fho Issuo
sfngo In ordor (In-ordor Issuo); howovor, fhoy cnn bo sfnIIod or bynss onch ofhor In fho
socond sfngo (rond oornnds) nnd fhus onfor oxocufIon ouf of ordor.
Score-IoorJing Is n fochnIquo for nIIowIng InsfrucfIons fo oxocufo ouf-of-ordor
whon fhoro nro suffIcIonf rosourcos nnd no dnfn doondoncos; If Is nnmod nffor fho CC
6600 scorobonrd, whIch dovoIood fhIs cnnbIIIfy.
Wo focus on n moro sohIsfIcnfod fochnIquo, cnIIod Tonoeulo`e olgoriIIn, fhnf
hns sovornI mnjor onhnncomonfs ovor scorobonrdIng.
Computev AvcLItectuve
TLunguveI Muvugun 105

ynumIc ScLeduIIng UsIng TomusuIo's AppvoucL
ThIs schomo wns Invonfod by !oborfTomnsuIo, nnd wns fIrsf usod In fho IIM
360/9l. If usos rogIsfor ronnmIng fo oIImInnfo oufuf nnd nnfI-doondoncIos, I.o. WAW
nnd WA! hnznrds. Oufuf nnd nnfI-doondoncIos nro jusf nnmo doondoncIos, fhoro Is
no ncfunI dnfn doondonco. TomnsuIo's nIgorIfhm ImIomonfs rogIsfor ronnmIng
fhrough fho uso of whnf nro cnIIod vesevvutIon stutIons. ResevvutIon stutIons nro
buffors whIch fofch nnd sforo InsfrucfIon oornnds ns soon ns fhoy nro nvnIInbIo.

In nddIfIon, ondIng InsfrucfIons dosIgnnfo fho rosorvnfIon sfnfIon fhnf wIII
rovIdo fhoIr Inuf. IInnIIy, whon succossIvo wrIfos fo n rogIsfor ovorIn In oxocufIon,
onIy fho Insf ono Is ncfunIIy usod fo udnfo fho rogIsfor. As InsfrucfIons nro Issuod, fho
rogIsfor socIfIos for ondIng oornnds nro ronnmod fo fho nnmos of fho rosorvnfIon
sfnfIon, whIch rovIdos rogIsfor ronnmIng. SInco fhoro cnn bo moro rosorvnfIon sfnfIons
fhnn ronI rogIsfors, fho fochnIquo cnn ovon oIImInnfo hnznrds nrIsIng from nnmo
doondoncos fhnf couId nof bo oIImInnfod by n comIIor.

Tho uso of rosorvnfIon sfnfIons, rnfhor fhnn n confrnIIzod rogIsfor fIIo, Ionds fo
fwo ofhor Imorfnnf roorfIos. IIrsf, hnznrd dofocfIon nnd oxocufIon confroI nro
dIsfrIbufod: Tho InformnfIon hoId In fho rosorvnfIon sfnfIons nf onch funcfIonnI unIf
doformIno whon nn InsfrucfIon cnn bogIn oxocufIon nf fhnf unIf. Socond, rosuIfs nro
nssod dIrocfIy fo funcfIonnI unIfs from fho rosorvnfIon sfnfIons whoro fhoy nro
bufforod, rnfhor fhnn goIng fhrough fho rogIsfors. ThIs bynssIng Is dono wIfh n
common rosuIf bus fhnf nIIows nII unIfs wnIfIng for nn oornnd fo bo Iondod
sImuIfnnoousIy (on fho 360/9l fhIs Is cnIIod fho connon JoIo Iue, or CI). In IoIInos
wIfh muIfIIo oxocufIon unIfs nnd IssuIng muIfIIo InsfrucfIons or cIock, moro fhnn
ono rosuIf bus wIII bo noodod.
Computev AvcLItectuve
TLunguveI Muvugun 106

TLe busIc stvuctuve oI u MIPS IIoutIng poInt unIt usIng TomusuIo's uIgovItLm.
IIguro shows fho bnsIc sfrucfuro of n TomnsuIo-bnsod MIIS rocossor, IncIudIng
bofh fho fIonfIng-oInf unIf nnd fho Iond/sforo unIf. InsfrucfIons nro sonf from fho
InsfrucfIon unIf Info fho InsfrucfIon quouo from whIch fhoy nro Issuod In IIIO ordor.
Tho rosorvnfIon sfnfIons IncIudo fho oornfIon nnd fho ncfunI oornnds, ns woII ns
InformnfIon usod for dofocfIng nnd rosoIvIng hnznrds.
!ond buffors hnvo fhroo funcfIons: hoId fho comononfs of fho offocfIvo nddross
unfII If Is comufod, frnck oufsfnndIng Ionds fhnf nro wnIfIng on fho momory, nnd hoId
fho rosuIfs of comIofod Ionds fhnf nro wnIfIng for fho CI. SImIInrIy, sforo buffors
hnvo fhroo funcfIons: hoId fho comononfs of fho offocfIvo nddross unfII If Is comufod,
hoId fho dosfInnfIon momory nddrossos of oufsfnndIng sforos fhnf nro wnIfIng for fho
dnfn vnIuo fo sforo, nnd hoId fho nddross nnd vnIuo fo sforo unfII fho momory unIf Is
nvnIInbIo.
Computev AvcLItectuve
TLunguveI Muvugun 10?
AII rosuIfs from oIfhor fho II unIfs or fho Iond unIf nro uf on fho CI, whIch
goos fo fho II rogIsfor fIIo ns woII ns fo fho rosorvnfIon sfnfIons nnd sforo buffors. Tho
II nddors ImIomonf nddIfIon nnd subfrncfIon, nnd fho II muIfIIIors do
muIfIIIcnfIon nnd dIvIsIon.

Thoro nro onIy fhroo sfos In TomnsuIo`s Arronch :
l. 1eeueCof fho noxf InsfrucfIon from fho hond of fho InsfrucfIon quouo. If fhoro Is
n mnfchIng rosorvnfIon sfnfIon fhnf Is omfy, Issuo fho InsfrucfIon fo fho sfnfIon
wIfh fho oornnd vnIuos (ronnmos rogIsfors)
2. 1xecuIe(1X) Whon nII fho oornnds nro nvnIInbIo, Inco Info fho corrosondIng
rosorvnfIon sfnfIons for oxocufIon. If oornnds nro nof yof nvnIInbIo, monIfor fho
common dnfn bus (CI) whIIo wnIfIng for If fo bo comufod.
3. WriIe reeulI (WB)Whon fho rosuIf Is nvnIInbIo, wrIfo If on fho CI nnd from
fhoro Info fho rogIsfors nnd Info nny rosorvnfIon sfnfIons (IncIudIng sforo
buffors) wnIfIng for fhIs rosuIf. Sforos nIso wrIfo dnfn fo momory durIng fhIs
sfo: Whon bofh fho nddross nnd dnfn vnIuo nro nvnIInbIo, fhoy nro sonf fo fho
momory unIf nnd fho sforo comIofos.
Tho fng fIoId doscrIbos whIch rosorvnfIon sfnfIon confnIns fho InsfrucfIon fhnf wIII
roduco n rosuIf noodod ns n sourco oornnd. Onco nn InsfrucfIon hns Issuod nnd Is
wnIfIng for n sourco oornnd, If rofors fo fho oornnd by fho rosorvnfIon sfnfIon numbor
whoro fho InsfrucfIon fhnf wIII wrIfo fho rogIsfor hns boon nssIgnod. !nusod vnIuos,
such ns zoro, IndIcnfo fhnf fho oornnd Is nIrondy nvnIInbIo In fho rogIsfors.Tho rogIsfor
nnmos nro dIscnrdod whon nn InsfrucfIon Issuos fo n rosorvnfIon sfnfIon.

Inch rosorvnfIon sfnfIon hns sIx fIoIds:
OTho oornfIon fo orform on sourco oornnds Sl nnd S2.
Qj, QkTho rosorvnfIon sfnfIons fhnf wIII roduco fho corrosondIng sourco
oornnd; n vnIuo of zoro IndIcnfos fhnf fho sourco oornnd Is nIrondy nvnIInbIo In
Vj or Vk, or Is unnocossnry.
Computev AvcLItectuve
TLunguveI Muvugun 10B
Vj, VkTho vnIuo of fho sourco oornnds. ofo fhnf onIy ono of fho V fIoId or fho
Q fIoId Is vnIId for onch oornnd. Ior Ionds, fho Vk fIoId Is usod fo fho offsof from
fho InsfrucfIon.
Ausod fo hoId InformnfIon for fho momory nddross cnIcuInfIon for n Iond or
sforo.
IusyIndIcnfos fhnf fhIs rosorvnfIon sfnfIon nnd Ifs nccomnnyIng funcfIonnI
unIf nro occuIod.

Tho rogIsfor fIIo hns n fIoId, QI:
QITho numbor of fho rosorvnfIon sfnfIon fhnf confnIns fho oornfIon whoso
rosuIf shouId bo sforod Info fhIs rogIsfor. If fho vnIuo of QI Is bInnk (or 0), no
curronfIy ncfIvo InsfrucfIon Is comufIng n rosuIf dosfInod for fhIs rogIsfor,
monnIng fhnf fho vnIuo Is sImIy fho rogIsfor confonfs.

2.4 YNAMIC SCHUIING: XAMPIS AN TH AIGORITHM
TomnsuIo`s schomo offors fwo mnjor ndvnnfngos ovor onrIIor nnd sImIor
schomos: (l) fho dIsfrIbufIon of fho hnznrd dofocfIon IogIc nnd (2) fho oIImInnfIon of
sfnIIs for WAW nnd WA! hnznrds.
Tho fIrsf ndvnnfngo nrIsos from fho dIsfrIbufod rosorvnfIon sfnfIons nnd fho uso
of fho CI. If muIfIIo InsfrucfIons nro wnIfIng on n sIngIo rosuIf, nnd onch InsfrucfIon
nIrondy hns Ifs ofhor oornnd, fhon fho InsfrucfIons cnn bo roIonsod sImuIfnnoousIy by
fho brondcnsf on fho CI. If n confrnIIzod rogIsfor fIIo woro usod, fho unIfs wouId hnvo
fo rond fhoIr rosuIfs from fho rogIsfors whon rogIsfor busos nro nvnIInbIo.
Tho socond ndvnnfngo, fho oIImInnfIon of WAW nnd WA! hnznrds, Is
nccomIIshod by ronnmIng rogIsfors usIng fho rosorvnfIon sfnfIons, nnd by fho rocoss
of sforIng oornnds Info fho rosorvnfIon sfnfIon ns soon ns fhoy nro nvnIInbIo.

TomusuIo's AIgovItLm: tLe detuIIs
!onds nnd sforos go fhrough n funcfIonnI unIf for offocfIvo nddross comufnfIon
boforo rocoodIng fo Indoondonf Iond or sforo buffors.
Computev AvcLItectuve
TLunguveI Muvugun 109
!onds fnko n socond oxocufIon sfo fo nccoss momory nnd fhon go fo WrIfo
!osuIf fo sond fho vnIuo from momory fo fho rogIsfor fIIo nnd/or nny wnIfIng
rosorvnfIon sfnfIons. Sforos comIofo fhoIr oxocufIon In fho WrIfo !osuIf sfngo, whIch
wrIfos fho rosuIf fo momory.

TomusuIo's AIgovItLm: A Ioop-Bused umpIe
To undorsfnnd fho fuII owor of oIImInnfIng WAW nnd WA! hnznrds fhrough dynnmIc
ronnmIng of rogIsfors, wo musf Iook nf n Ioo. ConsIdor fho onrIIor foIIowIng sImIo
soquonco for muIfIIyIng fho oIomonfs of nn nrrny by n scnInr In

I2:
!oo: !. I0,0(!l)
M!!. I4,I0,I2
S. I4,0(!l)
A!I !l,!l,-8
II !l,!2,!oo ; brnnchos If !l=0

A Iond nnd sforo cnn snfoIy bo dono In n dIfforonf ordor, rovIdod fhoy nccoss
dIfforonf nddrossos. If n Iond nnd n sforo nccoss fho snmo nddross, fhon oIfhor:
fho Iond Is boforo fho sforo In rogrnm ordor nnd InforchnngIng fhom rosuIfs In n
WA! hnznrd, or
Tho sforo Is boforo fho Iond In rogrnm ordor nnd InforchnngIng fhom rosuIfs In
n !AW hnznrd.

SImIInrIy, InforchnngIng fwo sforos fo fho snmo nddross rosuIfs In WAW hnznrd.
Honco, fo doformIno If n Iond cnn bo oxocufod nf n gIvon fImo, fho rocossor cnn chock
whofhor nny uncomIofod sforo fhnf rocodos fho Iond In rogrnm ordor shnros fho
snmo dnfn momory nddross ns fho Iond. SImIInrIy, n sforo musf wnIf unfII fhoro nro no
unoxocufod Ionds or sforos fhnf nro onrIIor In rogrnm ordor nnd shnro fho snmo dnfn
momory nddross.
Computev AvcLItectuve
TLunguveI Muvugun 110
!of`s consIdor fho sIfunfIon of n Iond fIrsf. If wo orform offocfIvo nddross
cnIcuInfIon In rogrnm ordor, fhon whon n Iond hns comIofod offocfIvo nddross
cnIcuInfIon, wo cnn chock whofhor fhoro Is nn nddross confIIcf by oxnmInIng fho A fIoId
of nII ncfIvo sforo buffors.
If fho Iond nddross mnfchos fho nddross of nny ncfIvo onfrIos In fho sforo buffor,
fho Iond InsfrucfIon Is nof sonf fo fho Iond buffor unfII fho confIIcfIng sforo
comIofos.Sforos oornfo sImIInrIy, oxcof fhnf fho rocossor musf chock for confIIcfs In
bofh fho Iond buffors nnd fho sforo buffors, sInco confIIcfIng sforos cnnnof bo roordorod
wIfh rosocf fo oIfhor n Iond or n sforo.
In TomnsuIo`s schomo fwo dIfforonf fochnIquos nro combInod: fho ronnmIng of
fho nrchIfocfurnI rogIsfors fo n Inrgor sof of rogIsfors nnd fho bufforIng of sourco
oornnds from fho rogIsfor fIIo. Sourco oornnd bufforIng rosoIvos WA! hnznrds fhnf
nrIso whon fho oornnd Is nvnIInbIo In fho rogIsfors.
TomnsuIo`s schomo Is nrfIcuInrIy nonIIng If fho dosIgnor Is forcod fo IoIIno
nn nrchIfocfuro for whIch If Is dIffIcuIf fo schoduIo codo, fhnf hns n shorfngo of rogIsfors,
or for whIch fho dosIgnor wIshos fo obfnIn hIgh orformnnco wIfhouf IoIIno socIfIc
comIInfIon. On fho ofhor hnnd, fho ndvnnfngos of fho TomnsuIo nronch vorsus
comIIor schoduIIng for n offIcIonf sIngIo-Issuo IoIIno nro robnbIy fowor fhnn fho
cosfs of ImIomonfnfIon.
Tho koy comononfs for onhnncIng I!I In TomnsuIo`s nIgorIfhm nro dynnmIc
schoduIIng, rogIsfor ronnmIng, nnd dynnmIc momory dIsnmbIgunfIon. Tho fochnIquos
nro usod for fwo urosos: fo rodIcf whofhor n brnnch wIII bo fnkon nnd fo fInd fho
fnrgof moro quIckIy.

2.5 RUCING BRANCH COSTS WITH YNAMIC HARWAR
PRICTION
Tho nmounf of I!I wo nffomf fo oxIoIf grows, confroI doondoncos rnIdIy
bocomo fho IImIfIng fncfor. AIfhough schomos In fhIs socfIon nro hoIfuI In rocossors
fhnf fry fo mnInfnIn ono InsfrucfIon Issuo or cIock, for fwo ronsons fhoy nro cruciol fo
nny rocossor fhnf frIos fo Issuo moro fhnn ono InsfrucfIon or cIock.

Computev AvcLItectuve
TLunguveI Muvugun 111
IIrsf, brnnchos wIII nrrIvo u fo n fImos fnsfor In nn n-Issuo rocossor nnd
rovIdIng nn InsfrucfIon sfronm fo fho rocossor wIII robnbIy roquIro fhnf wo rodIcf
fho oufcomo of brnnchos. Socond, AmdnhI`s !nw romInds us fhnf roInfIvo Imncf of fho
confroI sfnIIs wIII bo Inrgor wIfh fho Iowor ofonfInI CII In such mnchInos.
Tho gonI of nII fhoso mochnnIsms Is fo nIIow fho rocossor fo rosoIvo fho oufcomo
of n brnnch onrIy, fhus rovonfIng confroI doondoncos from cnusIng sfnIIs. Tho
offocfIvonoss of n brnnch rodIcfIon schomo doonds nof onIy on fho nccurncy, buf nIso
on fho cosf of n brnnch whon fho rodIcfIon Is corrocf nnd whon fho rodIcfIon Is
Incorrocf.

BusIc BvuncL PvedIctIon und BvuncL-PvedIctIon BuIIevs

Tho sImIosf dynnmIc brnnch-rodIcfIon schomo Is n IroncI-preJicIion Iuffer or
IroncI IieIor, IoIle. A brnnch-rodIcfIon buffor Is n smnII momory Indoxod by fho Iowor
orfIon of fho nddross of fho brnnch InsfrucfIon. Tho momory confnIns n bIf fhnf snys
whofhor fho brnnch wns roconfIy fnkon or nof. If fho rodIcfIon Is corrocfIf mny hnvo
boon uf fhoro by nnofhor brnnch fhnf hns fho snmo Iow-ordor nddross bIfs.

Tho rodIcfIon Is n hInf fhnf Is nssumod fo bo corrocf, nnd fofchIng bogIns In fho
rodIcfod dIrocfIon. If fho hInf furns ouf fo bo wrong, fho rodIcfIon bIf Is Invorfod nnd
sforod bnck. Tho orformnnco of fho buffor doonds on bofh how offon fho rodIcfIon Is
for fho brnnch of Inforosf nnd how nccurnfo fho rodIcfIon Is whon If mnfchos.

ThIs sImIo ono-bIf rodIcfIon schomo hns n orformnnco shorfcomIng: Ivon If n
brnnch Is nImosf nIwnys fnkon, wo wIII IIkoIy rodIcf IncorrocfIy fwIco, rnfhor fhnn
onco, whon If Is nof fnkon.

To romody fhIs, fwo-bIf rodIcfIon schomos nro offon usod. In n fwo-bIf schomo, n
rodIcfIon musf mIss fwIco boforo If Is chnngod. IIguro shows fho fInIfo-sfnfo rocossor
for n fwo-bIf rodIcfIon schomo.
Computev AvcLItectuve
TLunguveI Muvugun 112

TLe stutes In u two-bIt pvedIctIon scLeme.

Tho fwo bIfs nro usod fo oncodo fho four sfnfos In fho sysfom. In n counfor
ImIomonfnfIon, fho counfors nro Incromonfod whon n brnnch Is fnkon nnd
docromonfod whon If Is nof fnkon; fho counfors snfurnfo nf 00 or ll. Ono comIIcnfIon
of fho fwo-bIf schomo Is fhnf If udnfos fho rodIcfIon bIfs moro offon fhnn n ono-bIf
rodIcfor, whIch onIy udnfos fho rodIcfIon bIf on n mIsrodIcf. SInco wo fyIcnIIy rond
fho rodIcfIon bIfs on ovory cycIo, n fwo-bIf rodIcfor wIII fyIcnIIy nood bofh n rond nnd
n wrIfo nccoss orf.
Tho fwo-bIf schomo Is ncfunIIy n socInIIznfIon of n moro gonornI schomo fhnf
hns nn n-bIf snfurnfIng counfor for onch onfry In fho rodIcfIon buffor. WIfh nn n-bIf
counfor, fho counfor cnn fnko on vnIuos bofwoon 0 nnd 2
n
l: whon fho counfor Is
gronfor fhnn or oqunI fo ono hnIf of Ifs mnxImum vnIuo (2
nl
), fho brnnch Is rodIcfod ns
fnkon; ofhorwIso, If Is rodIcfod unfnkon.
As In fho fwo-bIf schomo, fho counfor Is Incromonfod on n fnkon brnnch nnd
docromonfod on nn unfnkon brnnch. SfudIos of n-bIf rodIcfors hnvo shown fhnf fho
fwo-bIf rodIcfors do nImosf ns woII, nnd fhus mosf sysfoms roIy on fwo-bIf brnnch
rodIcfors rnfhor fhnn fho moro gonornI n-bIf rodIcfors.

Computev AvcLItectuve
TLunguveI Muvugun 113
If fho InsfrucfIon Is docodod ns n brnnch nnd If fho brnnch Is rodIcfod ns fnkon,
fofchIng bogIns from fho fnrgof ns soon ns fho IC Is known. OfhorwIso, soquonfInI
fofchIng nnd oxocufIng confInuo. If fho rodIcfIon furns ouf fo bo wrong, fho rodIcfIon
bIfs nro chnngod ns shown In IIguro.
AIfhough fhIs schomo Is usofuI for mosf IoIInos, fho fIvo-sfngo, cInssIc IoIIno
fInds ouf bofh whofhor fho brnnch Is fnkon nnd whnf fho fnrgof of fho brnnch Is nf
roughIy fho snmo fImo, oeeuning no hnznrd In nccossIng fho rogIsfor socIfIod In fho
condIfIonnI brnnch.
To oxIoIf moro I!I, fho nccurncy of our brnnch rodIcfIon bocomos crIfIcnI, fhIs
robIom In fwo wnys: by IncronsIng fho sIzo of fho buffor nnd by IncronsIng fho nccurncy
of fho schomo wo uso for onch rodIcfIon.

CovveIutIng BvuncL PvedIctovs:
Thoso fwo-bIf rodIcfor schomos uso onIy fho roconf bohnvIor of n sIngIo brnnch
fo rodIcf fho fufuro bohnvIor of fhnf brnnch. If mny bo ossIbIo fo Imrovo fho
rodIcfIon nccurncy If wo nIso Iook nf fho roconf bohnvIor of oIIer brnnchos rnfhor fhnn
jusf fho brnnch wo nro fryIng fo rodIcf. ConsIdor n smnII codo frngmonf from fho
SIIC92 bonchmnrk
If (nn==2)
nn=0;
If (bb==2)
bb=0;
If (nn!=bb) {

Horo Is fho MIIS codo fhnf wo wouId fyIcnIIy gonornfo for fhIs codo frngmonf
nssumIng fhnf nn nnd bb nro nssIgnod fo rogIsfors !l nnd !2:

S!I!I !3,!l,#2
IIZ !3,!l ;brnnch bl (nn!=2)
A !l,!0,!0 ;nn=0
!l: S!I!I !3,!2,#2
Computev AvcLItectuve
TLunguveI Muvugun 114
IIZ !3,!2 ;brnnch b2(bb!=2)
A !2,!0,!0 ; bb=0
!2: S!I! !3,!l,!2 ;!3=nn-bb
IIQZ !3,!3 ;brnnch b3 (nn==bb)

!of`s InboI fhoso brnnchos bl, b2, nnd b3. Tho koy obsorvnfIon Is fhnf fho
bohnvIor of brnnch b3 Is corroInfod wIfh fho bohnvIor of brnnchos bl nnd b2. CIonrIy, If
brnnchos bl nnd b2 nro bofh nof fnkon (I.o., fho If condIfIons bofh ovnIunfo fo fruo nnd
nn nnd bb nro bofh nssIgnod 0), fhon b3 wIII bo fnkon, sInco nn nnd bb nro cIonrIy oqunI.
A rodIcfor fhnf usos onIy fho bohnvIor of n sIngIo brnnch fo rodIcf fho oufcomo of fhnf
brnnch cnn novor cnfuro fhIs bohnvIor.
Irnnch rodIcfors fhnf uso fho bohnvIor of ofhor brnnchos fo mnko n rodIcfIon
nro cnIIod correloIing preJicIore or Iuo-letel preJicIore.

Touvnument PvedIctovs: AduptIveIy CombInIng IocuI und GIobuI PvedIctovs
Tho rImnry mofIvnfIon for corroInfIng brnnch rodIcfors cnmo from fho
obsorvnfIon fhnf fho sfnndnrd 2-bIf rodIcfor usIng onIy IocnI InformnfIon fnIIod on
somo Imorfnnf brnnchos nnd fhnf by nddIng gIobnI InformnfIon, fho orformnnco couId
bo Imrovod. Tournnmonf rodIcfors fnko fhIs InsIghf fo fho noxf IovoI, by usIng
muIfIIo rodIcfors, usunIIy ono bnsod on gIobnI InformnfIon nnd ono bnsod on IocnI
InformnfIon, nnd combInIng fhom wIfh n soIocfor. Tournnmonf rodIcfors cnn nchIovo
bofh boffor nccurncy nf modIum sIzos (8Kb-32Kb) nnd nIso mnko uso of vory Inrgo
numbors of rodIcfIon bIfs offocfIvoIy.
Tournnmonf rodIcfors nro fho mosf ouInr form of nulIiletel IroncI
preJicIore. A muIfIIovoI brnnch rodIcfor uso sovornI IovoIs of brnnch rodIcfIon fnbIos
fogofhor wIfh nn nIgorIfhm for choosIng nmong fho muIfIIo rodIcfors; IxIsfIng
fournnmonf rodIcfors uso n 2-bIf snfurnfIng counfor or brnnch fo chooso nmong fwo
dIfforonf rodIcfors. Tho four sfnfos of fho counfor dIcfnfo whofhor fo uso rodIcfor l or
rodIcfor 2. Tho sfnfo frnnsIfIon dIngrnm Is shown In IIguro.

Computev AvcLItectuve
TLunguveI Muvugun 115

TLe stute tvunsItIon dIugvum Iov u touvnument pvedIctov Lus Iouv stutes
covvespondIng to wLIcL pvedIctov to use.

Tho ndvnnfngo of n fournnmonf rodIcfor Is Ifs nbIIIfy fo soIocf fho rIghf
rodIcfor for fho rIghf brnnch. IIguro shows how fho fournnmonf rodIcfor soIocfs
bofwoon n IocnI nnd gIobnI rodIcfor doondIng on fho bonchmnrk, ns woII ns on fho
brnnch. Tho nbIIIfy fo chooso bofwoon n rodIcfIon bnsod on sfrIcfIy IocnI InformnfIon
nnd ono IncorornfIng gIobnI InformnfIon on n or brnnch bnsIs Is nrfIcuInrIy crIfIcnI In
fho Infogor bonchmnrks.

TLe IvuctIon oI pvedIctIons comIng Ivom tLe IocuI pvedIctov Iov u touvnument
pvedIctov usIng tLe SPCB9 bencLmuvks.
Computev AvcLItectuve
TLunguveI Muvugun 116
IIguro Iooks nf fho orformnnco of fhroo dIfforonf rodIcfors (n IocnI 2-bIf
rodIcfor, n corroInfIng rodIcfor, nnd n fournnmonf rodIcfor) for dIfforonf numbors of
bIfs usIng SIIC89 ns fho bonchmnrk. As wo snw onrIIor, fho rodIcfIon cnnbIIIfy of fho
IocnI rodIcfor doos nof Imrovo boyond n corfnIn sIzo. Tho corroInfIng rodIcfor shows
n sIgnIfIcnnf Imrovomonf, nnd fho fournnmonf rodIcfor gonornfos sIIghfIy boffor
orformnnco.

TLe mIspvedIctIon vute Iov tLvee dIIIevent pvedIctovs on SPCB9 us tLe totuI
numbev oI bIts Is Incveused.

2.6 HIGH PRIORMANC INSTRUCTION IIVRY

BvuncL Tuvget BuIIevs
A brnnch-rodIcfIon cncho fhnf sforos fho rodIcfod nddross for fho noxf
InsfrucfIon nffor n brnnch Is cnIIod n brnnch-fnrgof buffor or brnnch-fnrgof cncho.
Ior fho cInssIc, fIvo-sfngo IoIIno, n brnnch-rodIcfIon buffor Is nccossod durIng
fho I cycIo, so fhnf nf fho ond of I wo know fho brnnch-fnrgof nddross (sInco If Is
comufod durIng I), fho fnII-fhrough nddross (comufod durIng II), nnd fho
rodIcfIon. Thus, by fho ond of I wo know onough fo fofch fho noxf rodIcfod
InsfrucfIon.
Computev AvcLItectuve
TLunguveI Muvugun 11?
Ior n brnnch-fnrgof buffor, wo nccoss fho buffor durIng fho II sfngo usIng fho
InsfrucfIon nddross of fho fofchod InsfrucfIon, n ossIbIo brnnch, fo Indox fho buffor. If
wo gof n hIf, fhon wo know fho rodIcfod InsfrucfIon nddross nf fho ond of fho II cycIo,
whIch Is ono cycIo onrIIor fhnn for n brnnch-rodIcfIon buffor.
Iocnuso wo nro rodIcfIng fho noxf InsfrucfIon nddross nnd wIII sond If ouf
boforo docodIng fho InsfrucfIon, wo musf know whofhor fho fofchod InsfrucfIon Is
rodIcfod ns n fnkon brnnch. IIguro shows whnf fho brnnch-fnrgof buffor Iooks IIko. If
fho IC of fho fofchod InsfrucfIon mnfchos n IC In fho buffor, fhon fho corrosondIng
rodIcfod IC Is usod ns fho noxf IC.

A bvuncL-tuvget buIIev
If n mnfchIng onfry Is found In fho brnnch-fnrgof buffor, fofchIng bogIns
ImmodInfoIy nf fho rodIcfod IC. ofo fhnf fho onfry musf bo for fhIs InsfrucfIon,
bocnuso fho rodIcfod IC wIII bo sonf ouf boforo If Is known whofhor fhIs InsfrucfIon Is
ovon n brnnch. If wo dId nof chock whofhor fho onfry mnfchod fhIs IC, fhon fho wrong
IC wouId bo sonf ouf for InsfrucfIons fhnf woro nof brnnchos, rosuIfIng In n sIowor
rocossor. Wo onIy nood fo sforo fho rodIcfod-fnkon brnnchos In fho brnnch-fnrgof
buffor, sInco nn unfnkon brnnch foIIows fho snmo sfrnfogy ns n non brnnch.
Computev AvcLItectuve
TLunguveI Muvugun 11B

IIguro shows fho sfos foIIowod whon usIng n brnnch-fnrgof buffor nnd whoro
fhoso sfos occur In fho IoIIno. Irom fhIs wo cnn soo fhnf fhoro wIII bo no brnnch
doIny If n brnnch-rodIcfIon onfry Is found In fho buffor nnd Is corrocf.


TLe steps InvoIved In LundIIng un InstvuctIon wItL u bvuncL-tuvget buIIev
Computev AvcLItectuve
TLunguveI Muvugun 119
Integvuted InstvuctIon IetcL UnIts
Tho roconf dosIgns hnvo usod nn Infogrnfod InsfrucfIon fofch unIf fhnf Infogrnfos
sovornI funcfIons:
l. Infogrnfod brnnch rodIcfIon: fho brnnch rodIcfor bocomos nrf of fho InsfrucfIon
fofch unIf nnd Is consfnnfIy rodIcfIng brnnchos, so fo drIvo fho fofch IoIIno.
2. InsfrucfIon rofofch: fo doIIvor muIfIIo InsfrucfIons or cIock, fho InsfrucfIon
fofch unIf wIII IIkoIy nood fo fofch nhond. Tho unIf nufonomousIy mnnngos fho
rofofchIng of InsfrucfIons, InfogrnfIng If wIfh brnnch rodIcfIon.
3. InsfrucfIon momory nccoss nnd bufforIng:.Tho InsfrucfIon fofch unIf nIso rovIdos
bufforIng, ossonfInIIy ncfIng ns nn on-domnnd unIf fo rovIdo InsfrucfIons fo fho
Issuo sfngo ns noodod nnd In fho qunnfIfy noodod.
Retuvn Addvess PvedIctovs
Tho concof of n smnII buffor of rofurn nddrossos oornfIng ns n sfnck Is usod fo
rodIcf fho rofurn nddross. ThIs sfrucfuro cnchos fho mosf roconf rofurn nddrossos:
ushIng n rofurn nddross on fho sfnck nf n cnII nnd oIng ono off nf n rofurn. If fho
cncho Is suffIcIonfIy Inrgo, If wIII rodIcf fho rofurns orfocfIy.

2.? TAKING AVANTAG OI MOR IIP WITH MUITIPI ISSU
Tho gonI of fho nulIiple-ieeue proceeeore, dIscussod In fhIs socfIon, Is fo nIIow
muIfIIo InsfrucfIons fo Issuo In n cIock cycIo. MuIfIIo-Issuo rocossors como In fwo
bnsIc fInvors: euperecolor rocossors nnd VI1W (vory Iong InsfrucfIon word)
rocossors.SuorscnInr rocossors Issuo vnryIng numbors of InsfrucfIons or cIock nnd
nro oIfhor sfnfIcnIIy schoduIod (usIng comIIor fochnIquos covorod In fho noxf chnfor)
or dynnmIcnIIy schoduIod usIng fochnIquos bnsod on TomnsuIo`s nIgorIfhm.
SfnfIcnIIy schoduIod rocossor uso In-ordor oxocufIon, whIIo dynnmIcnIIy
schoduIod rocossors uso ouf-of-ordor oxocufIon.V!IW rocossors, In confrnsf, Issuo n
fIxod numbor of InsfrucfIons formnffod oIfhor ns ono Inrgo InsfrucfIon or ns n fIxod
InsfrucfIon nckof wIfh fho nrnIIoIIsm nmong InsfrucfIons oxIIcIfIy IndIcnfod by fho
InsfrucfIon (honco, fhoy nro nIso known ns IIIC--IxIIcIfIy InrnIIoI InsfrucfIon
Comufors). V!IW nnd IIIC rocossors nro InhoronfIy sfnfIcnIIy schoduIod by fho
comIIor.
Computev AvcLItectuve
TLunguveI Muvugun 120

StutIcuIIy-ScLeduIed SupevscuIuv Pvocessovs
In n sfnfIcnIIy-schoduIod suorscnInr, InsfrucfIons Issuo In ordor nnd nII IoIIno
hnznrds nro chockod for nf Issuo fImo. Tho IoIIno confroI IogIc musf chock for hnznrds
nmong fho InsfrucfIons boIng Issuod In n gIvon cIock cycIo, ns woII ns nmong fho IssuIng
InsfrucfIons nnd nII fhoso sfIII In oxocufIon. If somo InsfrucfIon In fho InsfrucfIon
sfronm Is doondonf (I.o., wIII cnuso n dnfn hnznrd) or doosn`f moof fho Issuo crIforIn
(I.o., wIII cnuso n sfrucfurnI hnznrd), onIy fho InsfrucfIons rocodIng fhnf ono In
InsfrucfIon soquonco wIII bo Issuod.
In confrnsf, In V!IWs, fho comIIor hns comIofo rosonsIbIIIfy for cronfIng n
nckngo of InsfrucfIons fhnf cnn bo sImuIfnnoousIy Issuod, nnd fho hnrdwnro doos nof
dynnmIcnIIy mnko nny docIsIons nbouf muIfIIo Issuo. (As wo wIII soo, for oxnmIo, fho
InfoI IA-64 nrchIfocfuro roIIos on fho rogrnmmor fo doscrIbo fho rosonco of rogIsfor
doondoncos wIfhIn nn Issuo nckof.) Thus, wo sny fhnf n suorscnInr rocossor hns
J,nonic Issuo cnnbIIIfy, nnd n V!IW rocossor hns eIoIic Issuo cnnbIIIfy.

Throo fncfors IImIf fho orformnnco of fho fwo-Issuo dynnmIcnIIy schoduIod IoIIno:
l. Thoro Is nn ImbnInnco bofwoon fho funcfIonnI unIf sfrucfuro of fho IoIIno nnd
fho oxnmIo Ioo. ThIs ImbnInnco monns fhnf If Is ImossIbIo fo fuIIy uso fho II
unIfs. To romody fhIs, wo wouId nood fowor doondonf Infogor oornfIons or
Ioo. Tho noxf oInf Is n dIfforonf wny of IookIng nf fhIs IImIfnfIon.
2. Tho nmounf of ovorhond or Ioo IfornfIon Is vory hIgh: fwo of ouf of fIvo
InsfrucfIons (fho AI! nnd fho II) nro ovorhond.
3. Tho confroI hnznrd, whIch rovonfs us from sfnrfIng fho noxf !. boforo wo
know whofhor fho brnnch wns corrocfIy rodIcfod, cnusos n ono-cycIo onnIfy on
ovory Ioo IfornfIon. Tho noxf socfIon Infroducos n fochnIquo fhnf nddrossos fhIs
IImIfnfIon.




Computev AvcLItectuve
TLunguveI Muvugun 121
2.B HARWAR-BAS SPCUIATION
Tho fyo of codo schoduIIng whIch oxocufIvos InsfrucfIons boforo or nffor fho
brnnch InsfrucfIon whIch wIII nof nffocf fho rogrnm rosuIf Is know n ns SocuInfIon.
Hnrdwnro-bnsod socuInfIon combInos fhroo koy Idons: dynnmIc brnnch rodIcfIon fo
chooso whIch InsfrucfIons fo oxocufo, socuInfIon fo nIIow fho oxocufIon of InsfrucfIons
boforo fho confroI doondoncos nro rosoIvod nnd dynnmIc schoduIIng fo donI wIfh fho
schoduIIng of dIfforonf combInnfIons of bnsIc bIocks. Hnrdwnro-bnsod socuInfIon
foIIows fho rodIcfod fIow of dnfn vnIuos fo chooso whon fo oxocufo InsfrucfIons. ThIs
mofhod of oxocufIng rogrnms Is ossonfInIIy n JoIo-flou execuIion: oornfIons oxocufo
ns soon ns fhoIr oornnds nro nvnIInbIo.
Tho nronch Is ImIomonfod In n numbor of rocossors (IoworIC
603/604/C3/C4, MIIS !l0000/!l2000, InfoI IonfIum II/III/ 4, AIhn 2l264, nnd AM
K5/K6/AfhIon), Is fo ImIomonf socuInfIvo oxocufIon bnsod on TomnsuIo`s nIgorIfhm.
Tho koy Idon bohInd ImIomonfIng socuInfIon Is fo nIIow InsfrucfIons fo oxocufo
ouf of ordor buf fo forco fhom fo commIf in orJer nnd fo rovonf nny IrrovocnbIo ncfIon
unfII nn InsfrucfIon commIfs. In fho sImIo sIngIo-Issuo fIvo-sfngo IoIIno wo couId
onsuro fhnf InsfrucfIons commIffod In ordor, nnd onIy nffor nny oxcofIons for fhnf
InsfrucfIon hnd boon dofocfod, sImIy by movIng wrIfos fo fho ond of fho IoIIno.
Whon wo ndd socuInfIon, wo nood fo sonrnfo fho rocoss of comIofIng
oxocufIon from InsfrucfIon commIf, sInco InsfrucfIons mny fInIsh oxocufIon consIdornbIy
boforo fhoy nro rondy fo commIf. AddIng fhIs commIf hnso fo fho InsfrucfIon oxocufIon
soquonco roquIros somo chnngos fo fho soquonco ns woII ns nn nddIfIonnI sof of
hnrdwnro buffors fhnf hoId fho rosuIfs of InsfrucfIons fhnf hnvo fInIshod oxocufIon buf
hnvo nof commIffod. ThIs hnrdwnro buffor, whIch wo cnII fho reorJer Iuffer, Is nIso usod
fo nss rosuIfs nmong InsfrucfIons fhnf mny bo socuInfod.
Tho roordor buffor (!OI, for shorf) rovIdos nddIfIonnI rogIsfors In fho snmo wny
ns fho rosorvnfIon sfnfIons In TomnsuIo`s nIgorIfhm oxfond fho rogIsfor sof. Tho !OI
hoIds fho rosuIf of nn InsfrucfIon bofwoon fho fImo fho oornfIon nssocInfod wIfh fho
InsfrucfIon comIofos nnd fho fImo fho InsfrucfIon commIfs. Honco, fho !OI Is n sourco
of oornnds for InsfrucfIons, jusf ns fho rosorvnfIon sfnfIons rovIdo oornnds In
TomnsuIo`s nIgorIfhm.
Computev AvcLItectuve
TLunguveI Muvugun 122
Tho koy dIfforonco Is fhnf In TomnsuIo`s nIgorIfhm, onco nn InsfrucfIon wrIfos Ifs
rosuIf, nny subsoquonfIy Issuod InsfrucfIons wIII fInd fho rosuIf In fho rogIsfor fIIo.
WIfh socuInfIon, fho rogIsfor fIIo Is nof udnfod unfII fho InsfrucfIon commIfs; fhus,
fho !OI suIIos oornnds In fho InforvnI bofwoon comIofIon of InsfrucfIon oxocufIon
nnd InsfrucfIon commIf. Tho !OI Is sImIInr fho sforo buffor In TomnsuIo`s nIgorIfhm,
nnd wo Infogrnfo fho funcfIon of fho sforo buffor Info fho !OI for sImIIcIfy.
Inch onfry In fho !OI confnIns fhroo fIoIds: fho InsfrucfIon fyo, fho dosfInnfIon
fIoId, nnd fho vnIuo fIoId. Tho InsfrucfIon-fyo fIoId IndIcnfos whofhor fho InsfrucfIon Is
n brnnch, n sforo, or n rogIsfor oornfIon. Tho dosfInnfIon fIoId suIIos fho rogIsfor
numbor or fho momory nddross, whoro fho InsfrucfIon rosuIf shouId bo wrIffon. Tho
vnIuo fIoId Is usod fo hoId fho vnIuo of fho InsfrucfIon rosuIf unfII fho InsfrucfIon
commIfs.
IIguro shows fho hnrdwnro sfrucfuro of fho rocossor IncIudIng fho !OI. Tho !OI
comIofoIy roIncos fho sforo buffors.

TLe busIc stvuctuve oI u MIPS IP unIt usIng TomusuIo's uIgovItLm und
etended to LundIe specuIutIon.
Computev AvcLItectuve
TLunguveI Muvugun 123
Horo nro fho four sfos InvoIvod In InsfrucfIon oxocufIon:
l. 1eeueCof nn InsfrucfIon from fho InsfrucfIon quouo. Issuo fho InsfrucfIon If
fhoro Is nn omfy rosorvnfIon sfnfIon nnd nn omfy sIof In fho !OI, sond fho
oornnds fo fho rosorvnfIon sfnfIon If fhoy nvnIInbIo In oIfhor fho rogIsfors or fho
!OI for oxocufIon. If oIfhor nII rosorvnfIons nro fuII or fho !OI Is fuII, fhon
InsfrucfIon Issuo Is sfnIIod unfII bofh hnvo nvnIInbIo onfrIos. ThIs sfngo Is
somofImos cnIIod JiepoIcI In n dynnmIcnIIy schoduIod rocossor.
2. 1xecuIeIf ono or moro of fho oornnds Is nof yof nvnIInbIo, monIfor fho CI
(common dnfn bus) whIIo wnIfIng for fho rogIsfor fo bo comufod. Whon bofh
oornnds nro nvnIInbIo nf n rosorvnfIon sfnfIon, oxocufo fho oornfIon.
3. WriIe reeulIWhon fho rosuIf Is nvnIInbIo, wrIfo If on fho CI nnd from fho
CI Info fho !OI, ns woII ns fo nny rosorvnfIon sfnfIons wnIfIng for fhIs rosuIf.
If fho vnIuo fo bo sforod Is nof nvnIInbIo yof, fho CI musf bo monIforod unfII
fhnf vnIuo Is brondcnsf, nf whIch fImo fho VnIuo fIoId of fho !OI onfry of fho
sforo Is udnfod.
4. ConniIThoro nro fhroo dIfforonf soquoncos of ncfIons nf commIf doondIng on
whofhor fho commIffIng InsfrucfIon Is: n brnnch wIfh nn Incorrocf rodIcfIon, n
sforo, or nny ofhor InsfrucfIon (normnI commIf). Tho normnI commIf cnso occurs
whon nn InsfrucfIon ronchos fho hond of fho !OI nnd Ifs rosuIf Is rosonf In fho
buffor; nf fhIs oInf, fho rocossor udnfos fho rogIsfor wIfh fho rosuIf nnd
romovos fho InsfrucfIon from fho !OI. CommIffIng n sforo Is sImIInr oxcof fhnf
momory Is udnfod rnfhor fhnn n rosuIf rogIsfor. Whon n brnnch wIfh Incorrocf
rodIcfIon ronchos fho hond of fho !OI, If IndIcnfos fhnf fho socuInfIon wns
wrong. Tho !OI Is fIushod nnd oxocufIon Is rosfnrfod nf fho corrocf succossor of
fho brnnch. If fho brnnch wns corrocfIy rodIcfod, fho brnnch Is fInIshod. Somo
mnchInos cnII fhIs commIf hnso conpleIion or groJuoIion.

In rncfIco, mnchInos fhnf socuInfo fry fo rocovor ns onrIy ns ossIbIo nffor n
brnnch Is mIsrodIcfod. ThIs rocovory cnn bo dono by cIonrIng fho !OI for nII onfrIos
fhnf nonr nffor fho mIsrodIcfod brnnch, nIIowIng fhoso fhnf nro boforo fho brnnch In
fho !OI fo confInuo, nnd rosfnrfIng fho fofch nf fho corrocf brnnch succossor.
Computev AvcLItectuve
TLunguveI Muvugun 124
In socuInfIvo rocossors, howovor, orformnnco Is moro sonsIfIvo fo fho brnnch
rodIcfIon mochnnIsms, sInco fho Imncf of n mIsrodIcfIon wIII bo hIghor.Thus, nII fho
nsocfs of hnndIIng brnnchosrodIcfIon nccurncy, mIsrodIcfIon dofocfIon, nnd
mIsrodIcfIon rocovoryIncronso In Imorfnnco. IxcofIons nro hnndIod by nof
rocognIzIng fho oxcofIon unfII If Is rondy fo commIf. If n socuInfod InsfrucfIon rnIsos
nn oxcofIon, fho oxcofIon Is rocordod In fho !OI. If n brnnch mIsrodIcfIon nrIsos nnd
fho InsfrucfIon shouId nof hnvo boon oxocufod, fho oxcofIon Is fIushod nIong wIfh fho
InsfrucfIon whon fho !OI Is cIonrod. If fho InsfrucfIon ronchos fho hond of fho !OI,
fhon wo know If Is no Iongor socuInfIvo nnd fho oxcofIon shouId ronIIy bo fnkon.
Thoro Is nn Imorfnnf dIfforonco In how sforos nro hnndIod In n socuInfIvo
rocossor, vorsus In TomnsuIo`s nIgorIfhm. In TomnsuIo`s nIgorIfhm, n sforo cnn udnfo
momory whon If ronchos WrIfo !osuIfs (whIch onsuros fhnf fho offocfIvo nddross hns
boon cnIcuInfod) nnd fho dnfn vnIuo fo sforo Is nvnIInbIo. In n socuInfIvo rocossor, n
sforo udnfos momory onIy whon If ronchos fho hond of fho !OI.ThIs dIfforonco
onsuros fhnf momory Is nof udnfod unfII nn InsfrucfIon Is no Iongor socuInfIvo.

!AW hnznrds fhrough momory nro mnInfnInod by fwo rosfrIcfIons:
l. nof nIIowIng n Iond fo InIfInfo fho socond sfo of Ifs oxocufIon If nny ncfIvo !OI
onfry occuIod by n sforo hns nn osfInnfIon fIoId fhnf mnfchos fho vnIuo of fho
A fIoId of fho Iond, nnd
2. MnInfnInIng fho rogrnm ordor for fho comufnfIon of nn offocfIvo nddross of n
Iond wIfh rosocf fo nII onrIIor sforos.

MuItIpIe Issue wItL SpecuIutIon
Tho fwo chnIIongos of muIfIIo Issuo wIfh TomnsuIo`s nIgorIfhmInsfrucfIon
Issuo nnd monIforIng fho CIs for InsfrucfIon comIofIon--bocomo fho mnjor chnIIongos
for muIfIIo Issuo wIfh socuInfIon. In nddIfIon, fo mnInfnIn fhroughuf of gronfor fhnn
ono InsfrucfIon or cycIo, n socuInfIvo rocossor musf bo nbIo fo hnndIo muIfIIo
InsfrucfIon commIfs or cIock cycIo.


Computev AvcLItectuve
TLunguveI Muvugun 125
esIgn ConsIdevutIons Iov SpecuIutIve MucLInes
RegIstev venumIng vevsus Reovdev BuIIevs
Ono nIfornnfIvo fo fho uso of n !OI Is fho oxIIcIf uso of n Inrgor hysIcnI sof of
rogIsfors combInod wIfh rogIsfor ronnmIng. ThIs nronch buIIds on fho concof of
ronnmIng usod In TomnsuIo`s nIgorIfhm, buf oxfonds If. In TomnsuIo`s nIgorIfhm, fho
vnIuos of fho orcIiIecIuroll, tieiIle regieIere (!0,..., !3l nnd I0,...,I3l) nro confnInod,
nf nny oInf In oxocufIon, In somo combInnfIon of fho rogIsfor sof nnd fho rosorvnfIon
sfnfIons. WIfh fho nddIfIon of socuInfIon, rogIsfor vnIuos mny nIso fomornrIIy rosIdo
In fho !OI.
In fho rogIsfor ronnmIng nronch, nn oxfondod sof of hysIcnI rogIsfors Is usod
fo hoId bofh fho nrchIfocfurnIIy vIsIbIo rogIsfors ns woII ns fomornry vnIuos. Thus, fho
oxfondod rogIsfors roInco fho funcfIon bofh of fho !OI nnd fho rosorvnfIon sfnfIons.
urIng InsfrucfIon Issuo, n ronnmIng rocoss mns fho nnmos of nrchIfocfurnI rogIsfors
fo hysIcnI rogIsfor numbors In fho oxfondod rogIsfor sof, nIIocnfIng n now unusod
rogIsfor for fho dosfInnfIon. WAW nnd WA! hnznrds nro nvoIdod by ronnmIng of fho
dosfInnfIon rogIsfor, nnd socuInfIon rocovory Is hnndIod bocnuso n hysIcnI rogIsfor
hoIdIng nn InsfrucfIon dosfInnfIon doos nof bocomo fho nrchIfocfurnI rogIsfor unfII fho
InsfrucfIon commIfs. Tho ronnmIng mn Is n sImIo dnfn sfrucfuro fhnf suIIos fho
hysIcnI rogIsfor numbor of fho rogIsfor fhnf curronfIy corrosonds fo fho socIfIod
nrchIfocfurnI rogIsfor. ThIs sfrucfuro Is sImIInr Is sfrucfuro nnd funcfIon fo fho rogIsfor
sfnfus fnbIo In TomnsuIo`s nIgorIfhm.
An ndvnnfngo of fho ronnmIng nronch vorsus fho !OI nronch Is fhnf
InsfrucfIon commIf Is sImIIfIod, sInco If roquIros onIy fwo sImIo ncfIons: rocord fhnf
fho mnIng bofwoon nn nrchIfocfurnI rogIsfor numbor nnd hysIcnI rogIsfor numbor Is
no Iongor socuInfIvo, nnd froo u nny hysIcnI rogIsfors boIng usod fo hoId fho oIdor
vnIuo of fho nrchIfocfurnI rogIsfor.

How mucL to specuIute
Ono of fho sIgnIfIcnnf ndvnnfngos of socuInfIon Is Ifs nbIIIfy fo uncovor ovonfs
fhnf wouId ofhorwIso sfnII fho IoIIno onrIy, such ns cncho mIssos.
Computev AvcLItectuve
TLunguveI Muvugun 126
ThIs ofonfInI ndvnnfngo, howovor, comos wIfh n sIgnIfIcnnf ofonfInI
dIsndvnnfngo: fho rocossor mny socuInfo fhnf somo cosfIy oxcofIonnI ovonf occurs
nnd bogIn rocossIng fho ovonf, whon In fncf, fho socuInfIon wns Incorrocf.
To mnInfnIn somo of fho ndvnnfngo, whIIo mInImIzIng fho dIsndvnnfngos, mosf
IoIInos wIfh socuInfIon wIII nIIow onIy Iow-cosf oxcofIonnI ovonfs (such ns n fIrsf-
IovoI cncho mIss) fo bo hnndIod In socuInfIvo modo. If nn oxonsIvo oxcofIonnI ovonf
occurs, such ns n socond-IovoI cncho mIss or n T!I mIss, fho rocossor wIII wnIf unfII
fho InsfrucfIon cnusIng fho ovonf Is no Iongor socuInfIvo boforo hnndIIng fho ovonf.

SpecuIutIng tLvougL muItIpIe bvuncLes
Throo dIfforonf sIfunfIons cnn bonofIf from socuInfIng on muIfIIo brnnchos
sImuIfnnoousIy: n vory hIgh brnnch froquoncy, sIgnIfIcnnf cIusforIng of brnnchos, nnd
Iong doInys In funcfIonnI unIfs. SocuInfIng on muIfIIo brnnchos sIIghfIy comIIcnfos
fho rocoss of socuInfIon rocovory, buf Is sfrnIghfforwnrd ofhorwIso. A moro comIox
fochnIquo Is rodIcfIng nnd socuInfIng on moro fhnn ono brnnch or cycIo.

2.9 STUIS OI TH IIMITATIONS OI IIP
TLe Huvdwuve ModeI
An IdonI rocossor Is ono whoro nII nrfIfIcInI consfrnInfs on I!I nro romovod. Tho onIy
IImIfs on I!I In such n rocossor nro fhoso Imosod by fho ncfunI dnfn fIows oIfhor
fhrough rogIsfors or momory.
Tho nssumfIons mndo for nn IdonI or orfocf rocossor nro ns foIIows:
l. IegieIer renoningThoro nro nn InfInIfo numbor of vIrfunI rogIsfors nvnIInbIo nnd
honco nII WAW nnd WA! hnznrds nro nvoIdod nnd nn unboundod numbor of
InsfrucfIons cnn bogIn oxocufIon sImuIfnnoousIy.
2. BroncI preJicIionIrnnch rodIcfIon Is orfocf. AII condIfIonnI brnnchos nro
rodIcfod oxncfIy.
3. Junp preJicIionAII jums (IncIudIng jum rogIsfor usod for rofurn nnd comufod
jums) nro orfocfIy rodIcfod. Whon combInod wIfh orfocf brnnch rodIcfIon, fhIs Is
oquIvnIonf fo hnvIng n rocossor wIfh orfocf socuInfIon nnd nn unboundod buffor of
InsfrucfIons nvnIInbIo for oxocufIon.
Computev AvcLItectuve
TLunguveI Muvugun 12?
4. Menor,-oJJreee olioe onol,eieAII momory nddrossos nro known oxncfIy nnd n Iond
cnn bo movod boforo n sforo rovIdod fhnf fho nddrossos nro nof IdonfIcnI.
AssumfIons 2 nnd 3 oIImInnfo oll confroI doondoncos. !IkowIso, nssumfIons l nnd
4 oIImInnfo oll IuI IIe Irue dnfn doondoncos. Togofhor, fhoso four nssumfIons monn
fhnf on, InsfrucfIon In fho of fho rogrnm`s oxocufIon cnn bo schoduIod on fho cycIo
ImmodInfoIy foIIowIng fho oxocufIon of fho rodocossor on whIch If doonds.

IImItutIons on tLe WIndow SIze und MuImum Issue Count
A dynnmIc rocossor mIghf bo nbIo fo moro cIosoIy mnfch fho nmounf of nrnIIoIIsm
uncovorod by our IdonI rocossor. consIdor whnf fho orfocf rocossor musf do:
l. !ook nrbIfrnrIIy fnr nhond fo fInd n sof of InsfrucfIons fo Issuo, rodIcfIng nII
brnnchos orfocfIy.
2. !onnmo nII rogIsfor usos fo nvoId WA! nnd WAW hnznrds.
3. oformIno whofhor fhoro nro nny dnfn doondoncIos nmong fho InsfrucfIons In
fho Issuo nckof; If so, ronnmo nccordIngIy.
4. oformIno If nny momory doondoncos oxIsf nmong fho IssuIng InsfrucfIons nnd
hnndIo fhom nrorInfoIy.
5. IrovIdo onough roIIcnfod funcfIonnI unIfs fo nIIow nII fho rondy InsfrucfIons fo
Issuo.

ObvIousIy, fhIs nnnIysIs Is quIfo comIIcnfod. Ior oxnmIo, fo doformIno whofhor
n IssuIng InsfrucfIons hnvo nny rogIsfor doondoncos nmong fhom, nssumIng nII
InsfrucfIons nro rogIsfor-rogIsfor nnd fho fofnI numbor of rogIsfors Is unboundod,
roquIros comnrIsons.
2n-2+2n-4+....+2 = 2
I=l
n-l
I = |2 (n-l)n]/2 = n
2
-n
Thus, fo dofocf doondoncos nmong fho noxf 2000 InsfrucfIonsfho dofnuIf sIzo
wo nssumo In sovornI fIgurosroquIros nImosf four nillion comnrIsons! Ivon IssuIng
onIy 50 InsfrucfIons roquIros 2450 comnrIsons. ThIs cosf obvIousIy IImIfs fho numbor
of InsfrucfIons fhnf cnn bo consIdorod for Issuo nf onco.


Computev AvcLItectuve
TLunguveI Muvugun 12B


In oxIsfIng nnd nonr-form rocossors, fho cosfs nro nof quIfo so hIgh, sInco wo
nood onIy dofocf doondonco nIrs nnd fho IImIfod numbor of rogIsfors nIIows dIfforonf
soIufIons. Iurfhormoro, In n ronI rocossor, Issuo occurs In-ordor nnd doondonf
InsfrucfIons nro hnndIod by n ronnmIng rocoss fhnf nccommodnfos doondonf
ronnmIng In ono cIock. Onco InsfrucfIons nro Issuod, fho dofocfIon of doondoncos Is
hnndIod In n dIsfrIbufod fnshIon by fho rosorvnfIon sfnfIons or scorobonrd.
Tho sof of InsfrucfIons fhnf nro oxnmInod for sImuIfnnoous oxocufIon Is cnIIod
fho uinJou. Inch InsfrucfIon In fho wIndow musf bo kof In fho rocossor nnd fho
numbor of comnrIsons roquIrod ovory cIock Is oqunI fo fho mnxImum comIofIon rnfo
fImos fho wIndow sIzo fImos fho numbor of oornnds or InsfrucfIon (fodny fyIcnIIy 6 x
80 x 2= 960), sInco ovory ondIng InsfrucfIon musf Iook nf ovory comIofIng InsfrucfIon
for oIfhor of Ifs oornnds.
Thus, fho fofnI wIndow sIzo Is IImIfod by fho roquIrod sforngo, fho comnrIsons,
nnd n IImIfod Issuo rnfo, whIch mnkos Inrgor wIndow Ioss hoIfuI. To dnfo, fho wIndow
sIzo hns boon In fho rnngo of 32 fo l26, whIch cnn roquIro ovor 2,000 comnrIsons. Tho
HI IA 8600 roorfodIy hns ovor ?,000 comnrnfors! Tho wIndow sIzo dIrocfIy IImIfs fho
numbor of InsfrucfIons fhnf bogIn oxocufIon In n gIvon cycIo.

TLe IIects oI ReuIIstIc BvuncL und Jump PvedIctIon :
Our IdonI rocossor nssumos fhnf brnnchos cnn bo orfocfIy rodIcfod: Tho
oufcomo of nny brnnch In fho rogrnm Is known boforo fho fIrsf InsfrucfIon Is oxocufod.
IIguros show fho offocfs of moro ronIIsfIc rodIcfIon schomos In fwo dIfforonf formnfs.
Our dnfn Is for sovornI dIfforonf brnnch-rodIcfIon schomos vnryIng from orfocf fo no
rodIcfor. Wo nssumo n sonrnfo rodIcfor Is usod for jums. Jum rodIcfors nro
Imorfnnf rImnrIIy wIfh fho mosf nccurnfo brnnch rodIcfors, sInco fho brnnch
froquoncy Is hIghor nnd fho nccurncy of fho brnnch rodIcfors domInnfos.
Computev AvcLItectuve
TLunguveI Muvugun 129

IIP uvuIIubIe In u pevIect pvocessov Iov sI oI tLe SPC92 bencLmuvks.



TLe eIIect oI bvuncL-pvedIctIon scLemes
Computev AvcLItectuve
TLunguveI Muvugun 130

TLe eIIect oI bvuncL-pvedIctIon scLemes sovted by uppIIcutIon

Tho fIvo IovoIs of brnnch rodIcfIon shown In fhoso fIguros nro
l. PerfecIAII brnnchos nnd jums nro orfocfIy rodIcfod nf fho sfnrf of oxocufIon.
2. TournonenI-IoeeJ IroncI preJicIorTho rodIcfIon schomo usos n corroInfIng
fwo-bIf rodIcfor nnd n noncorroInfIng fwo-bIf rodIcfor fogofhor wIfh n soIocfor,
whIch choosos fho bosf rodIcfor for onch brnnch.
3. SIonJorJ Iuo-IiI preJicIor uiII 12 Iuo-IiI enIrieeIn nddIfIon, wo nssumo n l6-
onfry buffor fo rodIcf rofurns.
Computev AvcLItectuve
TLunguveI Muvugun 131
4. SIoIicA sfnfIc rodIcfor usos fho rofIIo hIsfory of fho rogrnm nnd rodIcfs fhnf
fho brnnch Is nIwnys fnkon or nIwnys nof fnkon bnsod on fho rofIIo.
5. Aoneo brnnch rodIcfIon Is usod, fhough jums nro sfIII rodIcfod. InrnIIoIIsm
Is InrgoIy IImIfod fo wIfhIn n bnsIc bIock.

BvuncL pvedIctIon uccuvucy: TLe IIects oI IInIte RegIstevs
Our IdonI rocossor oIImInnfos nII nnmo doondoncos nmong rogIsfor roforoncos usIng
nn InfInIfo sof of hysIcnI rogIsfors. IIguros show fho offocf of roducIng fho numbor of
rogIsfors nvnIInbIo for ronnmIng, ngnIn usIng fho snmo dnfn In fwo dIfforonf forms.
Iofh fho II nnd CI rogIsfors nro Incronsod by fho numbor of rogIsfors shown on fho
nxIs or In fho Iogond.


TLe eIIect oI IInIte numbevs oI vegIstevs uvuIIubIe Iov venumIng.
Computev AvcLItectuve
TLunguveI Muvugun 132


TLe veductIon In uvuIIubIe puvuIIeIIsm Is sIgnIIIcunt wLen Iewev tLun un
unbounded numbev oI venumIng vegIstevs uve uvuIIubIe.

IIguro shows fhnf fho Imncf of hnvIng onIy n fInIfo numbor of rogIsfors Is
sIgnIfIcnnf If oxfonsIvo nrnIIoIIsm oxIsfs. AIfhough fhoso grnhs show n Inrgo Imncf
on fho fIonfIng-oInf rogrnms, fho Imncf on fho Infogor rogrnms Is smnII rImnrIIy
bocnuso fho IImIfnfIons In wIndow sIzo nnd brnnch rodIcfIon hnvo IImIfod fho I!I
subsfnnfInIIy, mnkIng ronnmIng Ioss vnIunbIo.
Computev AvcLItectuve
TLunguveI Muvugun 133
In nddIfIon, nofIco fhnf fho roducfIon In nvnIInbIo nrnIIoIIsm Is sIgnIfIcnnf ovon
If 64 nddIfIonnI Infogor nnd 64 nddIfIonnI II rogIsfors nro nvnIInbIo for ronnmIng,
whIch Is moro fhnn fho numbor of oxfrn rogIsfors nvnIInbIo on nny oxIsfIng rocossor ns
of 2000. AIfhough rogIsfor ronnmIng Is obvIousIy crIfIcnI fo orformnnco, nn InfInIfo
numbor of rogIsfors Is obvIousIy nof rncfIcnI. Thus, for fho noxf socfIon, wo nssumo
fhnf fhoro nro 256 Infogor nnd 256 II rogIsfors nvnIInbIo for ronnmIngfnr moro fhnn
nny nnfIcInfod rocossor hns.

TLe IIects oI ImpevIect AIIus AnuIysIs
Our ofImnI modoI nssumos fhnf If cnn orfocfIy nnnIyzo nII momory doondoncos, ns
woII ns oIImInnfo nII rogIsfor nnmo doondoncos. Of courso, orfocf nIIns nnnIysIs Is nof
ossIbIo In rncfIco: Tho nnnIysIs cnnnof bo orfocf nf comIIo fImo, nnd If roquIros n
ofonfInIIy unboundod numbor of comnrIsons nf runfImo.


TLe eIIect oI vuvIous uIIus unuIysIs tecLnIques on tLe umount oI IIP.
Computev AvcLItectuve
TLunguveI Muvugun 134

TLe eIIect oI vuvyIng IeveIs oI uIIus unuIysIs on IndIvIduuI pvogvums.

IIguros show fho Imncf of fhroo ofhor modoIs of momory nIIns nnnIysIs, In nddIfIon fo
orfocf nnnIysIs. Tho fhroo modoIs nro:
l. GloIol/eIocl perfecIfhIs modoI doos orfocf rodIcfIons for gIobnI nnd sfnck
roforoncos nnd nssumos nII hon roforoncos confIIcf. ThIs modoI rorosonfs nn
IdonIIzod vorsIon of fho bosf comIIor-bnsod nnnIysIs schomos curronfIy In
roducfIon. !oconf nnd ongoIng rosonrch on nIIns nnnIysIs for oInfors shouId
Imrovo fho hnndIIng of oInfors fo fho hon In fho fufuro.
2. 1nepecIionfhIs modoI oxnmInos fho nccossos fo soo If fhoy cnn bo doformInod
nof fo Inforforo nf comIIo fImo. Ior oxnmIo, If nn nccoss usos !l0 ns n bnso
rogIsfor wIfh nn offsof of 20, fhon nnofhor nccoss fhnf usos !l0 ns n bnso rogIsfor
wIfh nn offsof of l00 cnnnof Inforforo. In nddIfIon, nddrossos bnsod on rogIsfors
Computev AvcLItectuve
TLunguveI Muvugun 135
fhnf oInf fo dIfforonf nIIocnfIon nrons (such ns fho gIobnI nron nnd fho sfnck
nron) nro nssumod novor fo nIIns. ThIs nnnIysIs Is sImIInr fo fhnf orformod by
mnny oxIsfIng commorcInI comIIors, fhough nowor comIIors cnn do boffor, nf
Ionsf for Ioo-orIonfod rogrnms.
3. AoneAII momory roforoncos nro nssumod fo confIIcf.

Tho dynnmIcnIIy schoduIod rocossors roIy on dynnmIc momory dIsnmbIgunfIon nnd nro
IImIfod by fhroo fncfors:

l. To ImIomonf orfocf dynnmIc dIsnmbIgunfIon for n gIvon Iond, wo musf know
fho momory nddrossos of nII onrIIor sforos fhnf nof yof commIffod, sInco n Iond
mny hnvo n doondonco fhrough momory on n sforo. Ono fochnIquo for roducIng
fhIs IImIfnfIon on In-ordor nddross cnIcuInfIon Is momory nddross socuInfIon.
WIfh momory nddross socuInfIon, fho rocossor oIfhor nssumos fhnf no such
momory doondoncos oxIsf or usos n hnrdwnro rodIcfIon mochnnIsm fo rodIcf
If n doondonco oxIsfs, sfnIIIng fho Iond If n doondonco Is rodIcfod. Of courso,
fho rocossor cnn bo wrong nbouf fho nbsonco of fho doondonco, so wo nood n
mochnnIsm fo dIscovor If n doondonco fruIy oxIsfs nnd fo rocovor If so. To
dIscovor If n doondonco oxIsfs, fho rocossor oxnmInos fho dosfInnfIon nddross
of onch comIofIng sforo fhnf Is onrIIor In rogrnm ordor fhnn fho gIvon Iond. If n
doondonco fhnf shouId hnvo boon onforcod occurs, fho rocossor usos fho
socuInfIvo rosfnrf mochnnIsm fo rodo fho Iond nnd fho foIIowIng InsfrucfIons

2. OnIy n smnII numbor of momory roforoncos cnn bo dIsnmbIgunfod or cIock cycIo.

3. Tho numbor of fho Iond/sforo buffors doformInos how much onrIIor or Infor In fho
InsfrucfIon sfronm n Iond or sforo mny bo movod.

Iofh fho numbor of sImuIfnnoous dIsnmbIgunfIons nnd fho numbor of fho Iond/ sforo
buffors wIII nffocf fho cIock cycIo fImo.

Computev AvcLItectuve
TLunguveI Muvugun 136

2.10 IIMITATIONS ON IIP IOR RAIIZABI PROCSSORS
Tho orformnnco of rocossors nn nmbIfIous IovoI of hnrdwnro suorf oqunI fo
or boffor fhnn whnf Is IIkoIy In fho noxf fIvo yonrs. In nrfIcuInr wo nssumo fho
foIIowIng fIxod nffrIbufos:
l. ! fo 64 InsfrucfIon Issuos or cIock wIfh no Issuo rosfrIcfIons. As wo dIscuss
Infor, fho rncfIcnI ImIIcnfIons of vory wIdo Issuo wIdfhs on cIock rnfo, IogIc
comIoxIfy, nnd owor mny bo fho mosf Imorfnnf IImIfnfIon on oxIoIfIng I!I.
2. A fournnmonf rodIcfor wIfh lK onfrIos nnd n l6-onfry rofurn rodIcfor. ThIs
rodIcfor Is fnIrIy comnrnbIo fo fho bosf rodIcfors In 2000; fho rodIcfor Is nof
n rImnry boffIonock.
3. Iorfocf dIsnmbIgunfIon of momory roforoncos dono dynnmIcnIIyfhIs Is nmbIfIous
buf orhns nffnInnbIo for smnII wIndow sIzos (nnd honco smnII Issuo rnfos nnd
Iond/sforo buffors) or fhrough n momory doondonco rodIcfor.
4. !ogIsfor ronnmIng wIfh 64 nddIfIonnI Infogor nnd 64 nddIfIonnI II
rogIsfors,oxcoodIng Inrgosf numbor nvnIInbIo on nny rocossor In 200l (4l nnd 4l
In fho AIhn 2l264), buf robnbIy onsIIy ronchnbIo wIfhIn fwo or fhroo yonrs.

IIguros show fho rosuIf for fhIs confIgurnfIon ns wo vnry fho wIndow sIzo.IIguro
shows fho nrnIIoIIsm vorsus wIndow sIzo. Tho mosf sfnrfIIng obsorvnfIon Is fhnf wIfh
fho ronIIsfIc rocossor consfrnInfs IIsfod nbovo, fho offocf of fho wIndow sIzo for fho
Infogor rogrnms Is nof so sovoro ns for II rogrnms. ThIs rosuIf oInfs fo fho koy
dIfforonco bofwoon fhoso fwo fyos of rogrnms.
Tho nvnIInbIIIfy of Ioo-IovoI nrnIIoIIsm In fwo of fho II rogrnms monns fhnf
fho nmounf of I!I fhnf cnn bo oxIoIfod Is hIghor, buf fhnf for Infogor rogrnms ofhor
fncforssuch ns brnnch rodIcfIon, rogIsfor ronnmIng, nnd Ioss nrnIIoIIsm fo sfnrf
wIfhnro nII Imorfnnf IImIfnfIons. ThIs obsorvnfIon Is crIfIcnI, bocnuso of fho
Incronsod omhnsIs on Infogor orformnnco In fho Insf fow yonrs. As wo wIII soo In fho
noxf socfIon, for n ronIIsfIc rocossor In 2000, fho ncfunI orformnnco IovoIs nro much
Iowor fhnn fhoso shown In IIguro.
Computev AvcLItectuve
TLunguveI Muvugun 13?

TLe umount oI puvuIIeIIsm uvuIIubIe Iov u wIde vuvIety oI wIndow sIzes und u
IIed ImpIementutIon wItL up to 64 Issues pev cIock.

TLe umount oI puvuIIeIIsm uvuIIubIe vevsus tLe wIndow sIze Iov u vuvIety oI
Integev und IIoutIng-poInt pvogvums wItL up to 64 uvbItvuvy InstvuctIon Issues
pev cIock.
Computev AvcLItectuve
TLunguveI Muvugun 13B

Beyond tLe IImIts oI tLIs study
!ImIfnfIons nro fwo fyos fhnf nrIso ovon for fho orfocf socuInfIvo rocossor nnd
IImIfnfIons fhnf nrIso for ono or moro ronIIsfIc modoIs. Of courso, nII fho IImIfnfIons In
fho fIrsf cInss nIy fo fho socond. Tho mosf Imorfnnf IImIfnfIons fhnf nIy ovon fo
fho orfocf modoI nro:
1. WAR unJ WAW huxurJo through memory: fho sfudy oIImInnfod WAW nnd
WA! hnznrds fhrough rogIsfor ronnmIng, buf nof In momory usngo. AIfhough, nf
fIrsf gInnco If mIghf nonr fhnf such cIrcumsfnncos nro rnro (osocInIIy WAW
hnznrds), fhoy nrIso duo fo fho nIIocnfIon of sfnck frnmos. A cnIIod rocoduro
rousos fho momory IocnfIons of n rovIous rocoduro on fho sfnck nnd fhIs cnn
Iond fo WAW nnd WA! hnznrds fhnf nro unnocossnrIIy IImIfIng. AusfIn nnd
SohI`s l992 nor oxnmInos fhIs Issuo.
2. Unneceooury JepenJenceo: wIfh InfInIfo numbors of rogIsfors, nII buf fruo
rogIsfor dnfn doondoncos nro romovod. Thoro nro, howovor, doondoncos nrIsIng
from oIfhor rocurroncos or codo gonornfIon convonfIons fhnf Infroduco
unnocossnry fruo dnfn doondoncos. Ono oxnmIo of fhoso Is fho doondonco on
fho confroI vnrInbIo In n sImIo do-Ioo: sInco fho confroI vnrInbIo Is Incromonfod
on ovory Ioo IfornfIon, fho Ioo confnIns nf Ionsf ono doondonco. As wo show In
fho noxf chnfor, Ioo unroIIIng nnd nggrossIvo nIgobrnIc ofImIznfIon cnn
romovo such doondonf comufnfIon.
WnII`s sfudy IncIudos n IImIfod nmounf of such ofImIznfIons, buf
nIyIng fhom moro nggrossIvoIy couId Iond fo Incronsod nmounfs of I!I. In
nddIfIon, corfnIn codo gonornfIon convonfIons Infroduco unnoodod doondoncos,
In nrfIcuInr fho uso of rofurn nddross rogIsfors nnd n rogIsfor for fho sfnck
oInfor (whIch Is Incromonfod nnd docromonfod In fho cnII/rofurn soquonco).
WnII romovos fho offocf of fho rofurn nddross rogIsfor, buf fho uso of n sfnck
oInfor In fho IInkngo convonfIon cnn cnuso unnocossnry doondoncos. IosfIff,
Croono, Tyson, nnd Mudgo oxIorod fho ndvnnfngos of romovIng fhIs consfrnInf
In n l999 nor.

Computev AvcLItectuve
TLunguveI Muvugun 139



3. Otercoming the Jutu flou limit: n roconf roosod Idon fo boosf I!I, whIch
goos boyond fho cnnbIIIfy of fho sfudy nbovo, Is tolue preJicIion. VnIuo
rodIcfIon consIsfs of rodIcfIng dnfn vnIuos nnd socuInfIng on fho rodIcfIon.
Thoro nro fwo obvIous usos of fhIs schomo: rodIcfIng dnfn vnIuos nnd
socuInfIng on fho rosuIf nnd rodIcfIng nddross vnIuos for momory nIIns
oIImInnfIon. Tho Inffor nffocfs nrnIIoIIsm onIy undor Ioss fhnn orfocf
cIrcumsfnncos,
4. VnIuo rodIcfIon hns ossIbIy fho mosf ofonfInI for IncronsIng I!I. DoIo tolue
preJicIion onJ epeculoIion rodIcfs dnfn vnIuos nnd usos fhom In dosfInnfIon
InsfrucfIons socuInfIvoIy. Such socuInfIon nIIows muIfIIo doondonf
InsfrucfIons fo bo oxocufod In fho snmo cIock cycIo, fhus IncronsIng fho ofonfInI
I!I. To bo offocfIvo, howovor, dnfn vnIuos musf bo rodIcfod vory nccurnfoIy,
sInco fhoy wIII bo usod by consumIng InsfrucfIons, jusf ns If fhoy woro corrocfIy
comufod. Thus, Innccurnfo rodIcfIon wIII Iond fo Incorrocf socuInfIon nnd
rocovory, jusf ns whon brnnchos nro mIsrodIcfod. Ono InsIghf fhnf gIvos somo
hoo Is fhnf corfnIn InsfrucfIons roduco fho snmo vnIuos wIfh hIgh froquoncy, so
If mny bo ossIbIo fo soIocfIvoIy rodIcf vnIuos for corfnIn InsfrucfIons wIfh hIgh
nccurncy. ObvIousIy, orfocf dnfn vnIuo rodIcfIon wouId Iond fo InfInIfo
nrnIIoIIsm, sInco ovory vnIuo of ovory InsfrucfIon couId bo rodIcfod n rIorI.

Thus, sfudyIng fho offocf of vnIuo rodIcfIon In fruo IImIf sfudIos Is dIffIcuIf nnd
hns nof yof boon dono. SovornI sfudIos hnvo oxnmInod fho roIo of vnIuo rodIcfIon In
oxIoIfIng I!I In moro ronIIsfIc rocossors (o.g., !InsfI, WIIkorson, nnd Shon In
l996). Tho oxfonf fo whIch gonornI vnIuo rodIcfIon wIII bo usod In ronI rocossors
romnIns uncIonr nf fho rosonf.



Computev AvcLItectuve
TLunguveI Muvugun 140
Ior n Ioss fhnn orfocf rocossor, fhoro nro sovornI Idons, whIch hnvo boon roosod,
fhnf couId oxoso moro I!I. Wo monfIon fho fwo mosf Imorfnnf horo:
l. AJJreee tolue preJicIion onJ epeculoIion rodIcfs momory nddross vnIuos nnd
socuInfos by roordorIng Ionds nnd sforos. ThIs fochnIquo oIImInnfos fho nood fo
comufo offocfIvo nddrossos In-ordor fo doformIno whofhor momory roforoncos
cnn bo roordorod, nnd couId rovIdo boffor nIInsIng nnnIysIs fhnn nny rncfIcnI
schomo. Iocnuso wo nood nof ncfunIIy rodIcf dnfn vnIuos, buf onIy If offocfIvo
nddrossos nro IdonfIcnI, fhIs fyo of rodIcfIon cnn bo nccomIIshod by sImIor
fochnIquos. !oconf rocossors IncIudo IImIfod vorsIons of fhIs fochnIquo nnd If
cnn bo oxocfod fhnf fufuro ImIomonfnfIons of nddross vnIuo rodIcfIon mny
yIoId nn nroxImnfIon fo orfocf nIIns nnnIysIs, nIIowIng rocossors fo oIImInnfo
fhIs IImIf fo oxIoIfIng I!I.
2. SocuInfIng on muIfIIo nfhs: fhIs Idon wns dIscussod by !nm nnd WIIson In
l992 nnd oxIorod In fho sfudy covorod In fhIs socfIon. Iy socuInfIng on
muIfIIo nfhs, fho cosf of Incorrocf rocovory Is roducod nnd moro nrnIIoIIsm
cnn bo uncovorod. If onIy mnkos sonso fo ovnIunfo fhIs schomo for n IImIfod
numbor of brnnchos, bocnuso fho hnrdwnro rosourcos roquIrod grow
oxononfInIIy. WnII`s l993 sfudy rovIdos dnfn for socuInfIng In bofh dIrocfIons
on u fo oIghf brnnchos. Whofhor such schomos ovor bocomo rncfIcnI, or
whofhor If wIII nIwnys bo boffor fo dovofo fho oquIvnIonf sIIIcon nron fo boffor
brnnch rodIcfors romnIns fo bo soon. In Chnfor 8, wo dIscuss fhrond-IovoI
nrnIIoIIsm nnd fho uso of socuInfIvo fhronds.

If Is crIfIcnI fo undorsfnnd fhnf nono of fho IImIfs In fhIs socfIon nro fundnmonfnI
In fho sonso fhnf ovorcomIng fhom roquIros n chnngo In fho Inws of hysIcs! Insfond,
fhoy nro rncfIcnI IImIfnfIons fhnf ImIy fho oxIsfonco of somo formIdnbIo bnrrIors fo
oxIoIfIng nddIfIonnI I!I. Thoso IImIfnfIonswhofhor fhoy bo wIndow sIzo, nIIns
dofocfIon, or brnnch rodIcfIonrorosonf chnIIongos for dosIgnors nnd rosonrchors fo
ovorcomo! As wo dIscuss In fho concIudIng romnrks, fhoro nro n vnrIofy of ofhor
rncfIcnI Issuos fhnf mny ncfunIIy bo fho moro sorIous IImIfs fo oxIoIfIng I!I In fufuro
rocossors.
Computev AvcLItectuve
TLunguveI Muvugun 141


2.11 TLe P6 MIcvouvcLItectuve
Tho InfoI I6 mIcronrchIfocfuro forms fho bnsIs for fho IonfIum Iro, IonfIum II,
nnd fho IonfIum III. Tho I6 mIcronrchIfocfuro Is n dynnmIcnIIy schoduIod rocossor
fhnf frnnsInfos onch IA-32 InsfrucfIon fo n sorIos of mIcro-oornfIons (uos) fhnf nro
oxocufod by fho IoIIno; fho uos nro sImIInr fo fyIcnI !ISC InsfrucfIons. ! fo fhroo
IA-32 InsfrucfIons nro fofchod, docodod, nnd frnnsInfod Info uos ovory cIock cycIo.
If nn IA-32 InsfrucfIon roquIros moro fhnn four uos, If Is ImIomonfod by n
mIcrocodod soquonco fhnf gonornfos fho nocossnry uos In muIfIIo cIock cycIos. Tho
mnxImum numbor of uos fhnf mny bo gonornfod or cIock cycIo Is sIx, wIfh four
nIIocnfod fo fho fIrsf IA-32 InsfrucfIon, nnd ono uo sIof fo onch of fho romnInIng fwo
IA-32 InsfrucfIons.

Tho uos nro oxocufod by nn ouf-of-ordor socuInfIvo IoIIno usIng rogIsfor ronnmIng
nnd n !OI. Tho IoIIno Is sfrucfurod In l4 sfngos comosod of fho foIIowIng:
8 sfngos nro usod for In-ordor InsfrucfIon fofch, docodo, nnd dIsnfch. Tho noxf
InsfrucfIon Is soIocfod durIng fofch usIng n 5l2-onfry, fwo-IovoI brnnch rodIcfor.
Tho docodo nnd Issuo sfngos IncIudIng rogIsfor ronnmIng (usIng 40 vIrfunI
rogIsfors) nnd dIsnfch fo ono of 20 rosorvnfIon sfnfIons nnd fo ono of 40 onfrIos
In fho !OI.
3 sfngos nro usod for ouf-of-ordor oxocufIon In ono of fIvo sonrnfo funcfIonnI
unIfs (Infogor unIf, II unIf, brnnch unIf, momory nddross unIf, nnd momory
nccoss unIf). Tho oxocufIon IoIIno Is from l cycIo (for sImIo Infogor A!!
oornfIons) fo 32 cycIos for II dIvIdo. Tho Issuo rnfo nnd Infoncy of somo fyIcnI
oornfIons nonrs In IIguro 3.48.
3 sfngos nro usod for InsfrucfIon commIf.

Computev AvcLItectuve
TLunguveI Muvugun 142

TLe Iutency und vepeut vute Iov common uops In tLe P6 mIcvouvcLItectuve.

PevIovmunce oI tLe PentIum Pvo ImpIementutIon
Tho IonfIum Iro hns fho smnIIosf sof of rImnry cnchos nmong fho I6 bnsod
mIcrorocossors; If hns, howovor, n hIgh bnndwIdfh Inforfnco fo fho socondnry cnchos.
Thus, whIIo wo wouId oxocf moro orformnnco fo bo Iosf fo cncho mIssos fhnn on fho
IonfIum II, fho roInfIvoIy fnsfor nnd hIghor bnndwIdfh socondnry cnchos shouId roduco
fhIs offocf somowhnf. Tho monsuromonfs In fhIs socfIon uso n 200 MHz IonfIum Iro
wIfh n 256KI socondnry cncho nnd n 66 MHz mnIn momory bus.

TLe P6 pvocessov pIpeIIne sLowIng tLe tLvougLput oI eucL stuge und tLe totuI
buIIevIng pvovIded between stuges.
Tho Inck of InsfrucfIons fo comIofo monns fhnf somowhoro onrIIor In fho IoIIno, somo
InsfrucfIons fnIIod fo mnko rogross (or In fho IImIf, fnIIod fo ovon Issuo). ThIs bIockngo
cnn occur for n combInnfIon of sovornI ronsons In fho IonfIum Iro:
l. !oss fhnn n fhroo IA-32 InsfrucfIons couId bo fofchod, duo fo InsfrucfIon cncho
mIssos.
2. !oss fhnn fhroo InsfrucfIons couId Issuo, bocnuso ono of fho fhroo IA-32
InsfrucfIons gonornfod moro fhnn fho nIIocnfod numbor of uos (4 for fho fIrsf
InsfrucfIon nnd l for onch of ofhor fwo).
3. of nII fho mIcrooornfIons gonornfod In n cIock cycIo couId Issuo bocnuso of n
shorfngo of rosorvnfIon sfnfIons or roordor buffors.
Computev AvcLItectuve
TLunguveI Muvugun 143
4. A dnfn doondonco Iod fo n sfnII bocnuso ovory rosorvnfIons sfnfIon or fho
roordor buffor wns fIIIod wIfh InsfrucfIons fhnf nro doondonf.
5. A dnfn cncho mIssos Iod fo n sfnII bocnuso ovory rosorvnfIon sfnfIon or fho
roordor buffor wns fIIIod wIfh InsfrucfIons wnIfIng for n cncho mIss.
6. Irnnch mIsrodIcfs cnuso sfnIIs dIrocfIy, sInco fho IoIIno wIII nood fo bo
fIushod nnd rofIIIod. A mIsrodIcf cnn nIso cnuso n sfnII fhnf nrIsos from
Inforforonco bofwoon socuInfod InsfrucfIons fhnf wIII bo cnncoIod nnd
InsfrucfIons fhnf wIII bo comIofod.

StuIIs In tLe ecode CycIe
AIfhough fho rocossor nffomfs fo fofch fhroo InsfrucfIons ovory cycIo, If cnnnof
mnInfnIn fhIs rnfo If fho InsfrucfIon cncho gonornfos n mIss, If ono of fho InsfrucfIons
roquIros moro fhnn fho numbor of mIcrooornfIons nvnIInbIo fo If or If fho sIx-onfry uo
Issuo buffor Is fuII. If bronks ouf fho sfnIIs nf docodo fImo nccordIng fo whofhor fhoy nro
duo fo InsfrucfIon cncho sfnIIs, whIch Iond fo Ioss fhnn fhroo InsfrucfIons nvnIInbIo fo
docodo, or rosourco cnncIfy IImIfnfIons, whIch monns fhnf n Inck of rosorvnfIon sfnfIon
or roordor buffors rovonfs n uo from IssuIng. InIIuro fo Issuo n uo, ovonfunIIy Ionds
fo n fuII uo buffor (rocnII fhnf If hns sIx onfrIos), whIch fhon bIocks InsfrucfIon docodo.
Tho InsfrucfIon cncho mIss rnfo for fho SIIC95 II bonchmnrks Is smnII, nnd,
for mosf of fho II bonchmnrks, rosourco cnncIfy Is fho rImnry cnuso of docodo sfnIIs.
Tho rosourco IImIfnfIon nrIsos bocnuso of Inck of rogross furfhor down fho IoIIno,
duo oIfhor fo Inrgo numbors of doondonf oornfIons or fo Iong Infoncy oornfIons; fho
Inffor Is n IImIfnfIon for fIonfIng oInf rogrnms, In nrfIcuInr.

utu CucLe BeLuvIov
Tho numbor of fIrsf IovoI (!l) nnd socond IovoI (!2) cncho mIssos or fhousnnd
InsfrucfIons. Tho !2 mIssos, nIfhough smnIIor In numbor, cosf moro fhnn fIvo fImos ns
much ns !l mIssos, nnd fhus, domInnfo In somo nIIcnfIons. InsfrucfIon cncho mIssos
nro n mInor offocf In mosf of fho rogrnms.


Computev AvcLItectuve
TLunguveI Muvugun 144

BvuncL PevIovmunce und SpecuIutIon Costs
Irnnch fnrgof nddrossos nro rodIcfod wIfh n 5l2-onfry ITI, bnsod on fho fwo-IovoI
ndnfIvo schomo of Yoh nnd Inff. If fho ITI doos nof hIf, n sfnfIc rodIcfIon Is usod:
bnckwnrd brnnchos nro rodIcfod fnkon (nnd hnvo n ono cycIo onnIfy If corrocfIy
rodIcfod) nnd forwnrd brnnchos nro rodIcfod nof fnkon (nnd hnvo no onnIfy If
corrocfIy rodIcfod). Irnnch mIsrodIcfs hnvo bofh n dIrocf orformnnco onnIfy, whIch
Is bofwoon l0-l5 cycIos, nnd nn IndIrocf onnIfy duo fo fho ovorhond of IncorrocfIy
socuInfod InsfrucfIons, whIch Is ossonfInIIy ImossIbIo fo monsuro.

****N***
















Computev AvcLItectuve
TLunguveI Muvugun 145
UNIT III
INSTRUCTION IVI PARAIIIISM WITH SOITWAR
APPROACH

3.1 BASIC COMPIIR TCHNIQUS IOR XPOSING IIP
BusIc PIpeIIne ScLeduIIng und Ioop UnvoIIIng
To nvoId n IoIIno sfnII, n doondonf InsfrucfIon musf bo sonrnfod from fho
sourco InsfrucfIon by n dIsfnnco In cIock cycIos oqunI fo fho IoIIno Infoncy of fhnf
sourco InsfrucfIon. A comIIor`s nbIIIfy fo orform fhIs schoduIIng doonds bofh on fho
nmounf of I!I nvnIInbIo In fho rogrnm nnd on fho InfoncIos of fho funcfIonnI unIfs In
fho IoIIno. Throughouf fhIs chnfor wo wIII nssumo fho II unIf InfoncIos shown In
IIguro.

IutencIes oI IP opevutIons
Tho fIrsf coIumn shows fho orIgInnfIng InsfrucfIon fyo. Tho socond coIumn Is
fho fyo of fho consumIng InsfrucfIon. Tho Insf coIumn Is fho numbor of InforvonIng
cIock cycIos noodod fo nvoId n sfnII.
Wo wIII roIy on nn oxnmIo sImIInr fo fho ono wo usod In fho Insf chnfor, nddIng
n scnInr fo n vocfor:
Iov (I=l000; I>0; I=Il)
x|I] = x|I] + s;
ThIs Ioo Is nrnIIoI by nofIcIng fhnf fho body of onch IfornfIon Is Indoondonf.
Tho fIrsf sfo Is fo frnnsInfo fho nbovo sogmonf fo MIIS nssombIy Inngungo. In fho
foIIowIng codo sogmonf, !lIs InIfInIIy fho nddross of fho oIomonf In fho nrrny wIfh fho
hIghosf nddross, nnd I2 confnIns fho scnInr vnIuo, s. !ogIsfor !2 Is rocomufod, so
fhnf 8(!2) Is fho Insf oIomonf fo oornfo on.
Computev AvcLItectuve
TLunguveI Muvugun 146
Tho sfrnIghfforwnrd MIIS codo, nof schoduIod for fho IoIIno, Iooks IIko fhIs:
!oo: !. I0,0(!l) ;I0=nrrny oIomonf
A. I4,I0,I2 ;ndd scnInr In I2
S. I4,0(!l) ;sforo rosuIf
A!I !l,!l,#-8 ;docromonf oInfor
;8 byfos (or W)
II !l,!2,!oo ;brnnch !l!=zoro

!of`s sfnrf by sooIng how woII fhIs Ioo wIII run whon If Is schoduIod on n sImIo
IoIIno for MIIS wIfh fho InfoncIos from IIguro.
CIock cycIo Issuod
!oo: !. I0,0(!l) l
SIoll 2
A. I4,I0,I2 3
SIoll 4
SIoll 5
S. I4,0(!l) 6
A!I !l,!l,#-8 ?
SIoll 8
II !l,!2,!oo 9
SIoll l0
ThIs codo roquIros l0 cIock cycIos or IfornfIon. Wo cnn schoduIo fho Ioo fo obfnIn onIy
ono sfnII:
!oo: !. I0,0(!l)
A!I !l,!l,#-8
A. I4,I0,I2
SIoll
II !l,!2,
!oo ;doInyod brnnch
S. I4,8(!l) ;nIforod & Inforchnngod wIfh A!I
Computev AvcLItectuve
TLunguveI Muvugun 14?
IxocufIon fImo hns boon roducod from l0 cIock cycIos fo 6.Tho sfnII nffor A.
Is for fho uso by fho S.. In fho nbovo oxnmIo, wo comIofo ono Ioo IfornfIon nnd sforo
bnck ono nrrny oIomonf ovory 6 cIock cycIos, buf fho ncfunI work of oornfIng on fho
nrrny oIomonf fnkos jusf 3 (fho Iond, ndd, nnd sforo) of fhoso 6 cIock cycIos. Tho
romnInIng 3 cIock cycIos consIsf of Ioo ovorhondfho A!I nnd IInnd n sfnII.
To oIImInnfo fhoso 3 cIock cycIos wo nood fo gof moro oornfIons wIfhIn fho Ioo roInfIvo
fo fho numbor of ovorhond InsfrucfIons.
A sImIo schomo for IncronsIng fho numbor of InsfrucfIons roInfIvo fo fho brnnch
nnd ovorhond InsfrucfIons Is loop unrolling. !nroIIIng sImIy roIIcnfos fho Ioo body
muIfIIo fImos, ndjusfIng fho Ioo formInnfIon codo.
!oo unroIIIng cnn nIso bo usod fo Imrovo schoduIIng. Iocnuso If oIImInnfos fho
brnnch, If nIIows InsfrucfIons from dIfforonf IfornfIons fo bo schoduIod fogofhor. In fhIs
cnso, wo cnn oIImInnfo fho dnfn uso sfnII by cronfIng nddIfIonnI Indoondonf
InsfrucfIons wIfhIn fho Ioo body. If wo sImIy roIIcnfod fho InsfrucfIons whon wo
unroIIod fho Ioo, fho rosuIfIng uso of fho snmo rogIsfors couId rovonf us from
offocfIvoIy schoduIIng fho Ioo. Thus, wo wIII wnnf fo uso dIfforonf rogIsfors for onch
IfornfIon, IncronsIng fho roquIrod rogIsfor counf.
In ronI rogrnms wo do nof usunIIy know fho uor bound on fho Ioo. Suoso If
Is n, nnd wo wouId IIko fo unroII fho Ioo fo mnko l coIos of fho body. Insfond of n
sIngIo unroIIod Ioo, wo gonornfo n nIr of consocufIvo Ioos. Tho fIrsf oxocufos (n mod
l) fImos nnd hns n body fhnf Is fho orIgInnI Ioo. Tho socond Is fho unroIIod body
surroundod by nn oufor Ioo fhnf Ifornfos (n/l) fImos. Ior Inrgo vnIuos of n, mosf of fho
oxocufIon fImo wIII bo sonf In fho unroIIod Ioo body.

Summuvy oI tLe Ioop UnvoIIIng und ScLeduIIng umpIe
To obfnIn fho fInnI unroIIod codo wo hnd fo mnko fho foIIowIng docIsIons nnd
frnnsformnfIons:
l. oformIno fhnf If wns IognI fo movo fho S. nffor fho A!I nnd II, nnd
fInd fho nmounf fo ndjusf fho S. offsof.
2. oformIno fhnf unroIIIng fho Ioo wouId bo usofuI by fIndIng fhnf fho Ioo
IfornfIons woro Indoondonf, oxcof for fho Ioo mnInfonnnco codo.
Computev AvcLItectuve
TLunguveI Muvugun 14B
3. !so dIfforonf rogIsfors fo nvoId unnocossnry consfrnInfs fhnf wouId bo forcod by
usIng fho snmo rogIsfors for dIfforonf comufnfIons.
4. IIImInnfo fho oxfrn fosf nnd brnnch InsfrucfIons nnd ndjusf fho Ioo formInnfIon
nnd IfornfIon codo.
5. oformIno fhnf fho Ionds nnd sforos In fho unroIIod Ioo cnn bo Inforchnngod by
obsorvIng fhnf fho Ionds nnd sforos from dIfforonf IfornfIons nro Indoondonf.
ThIs frnnsformnfIon roquIros nnnIyzIng fho momory nddrossos nnd fIndIng fhnf
fhoy do nof rofor fo fho snmo nddross.
6. SchoduIo fho codo, rosorvIng nny doondoncos noodod fo yIoId fho snmo rosuIf
ns fho orIgInnI codo.

Tho koy roquIromonf undorIyIng nII of fhoso frnnsformnfIons Is nn
undorsfnndIng of how nn InsfrucfIon doonds on nnofhor nnd how fho InsfrucfIons cnn
bo chnngod or roordorod gIvon fho doondoncos.
Thoro nro fhroo dIfforonf fyos of IImIfs fo fho gnIns fhnf cnn bo nchIovod by Ioo
unroIIIng: n docronso In fho nmounf of ovorhond nmorfIzod wIfh onch unroII, codo sIzo
IImIfnfIons, nnd comIIor IImIfnfIons. !of`s consIdor fho quosfIon of Ioo ovorhond fIrsf.
Whon wo unroIIod fho Ioo four fImos, If gonornfod suffIcIonf nrnIIoIIsm nmong fho
InsfrucfIons fhnf fho Ioo couId bo schoduIod wIfh no sfnII cycIos. A socond IImIf fo
unroIIIng Is fho growfh In codo sIzo fhnf rosuIfs.

3.2 STATIC BRANCH PRICTION
SfnfIc brnnch rodIcfors nro usod In rocossors whoro fho oxocfnfIon Is fhnf
brnnch bohnvIor Is hIghIy rodIcfnbIo nf comIIo-fImo; sfnfIc rodIcfIon cnn nIso bo usod
fo nssIsf dynnmIc rodIcfors.
An nrchIfocfurnI fonfuro fhnf suorfs sfnfIc brnnch rodIcnfIon, nnmoIy doInyod
brnnchos. oInyod brnnchos oxoso n IoIIno hnznrd so fhnf fho comIIor cnn roduco
fho onnIfy nssocInfod wIfh fho hnznrd. Tho offocfIvonoss of fhIs fochnIquo nrfIy
doonds on whofhor wo corrocfIy guoss whIch wny n brnnch wIII go.
Computev AvcLItectuve
TLunguveI Muvugun 149
IoIng nbIo fo nccurnfoIy rodIcf n brnnch nf comIIo fImo Is nIso hoIfuI for
schoduIIng dnfn hnznrds. !oo unroIIIng Is on sImIo oxnmIo of fhIs; nnofhor oxnmIo,
nrIsos from condIfIonnI soIocfIon brnnchos. ConsIdor fho foIIowIng codo sogmonf:

! !l,0(!2)
S!I! !l,!l,!3
IIQZ !l,!
O! !4,!5,!6
A! !l0,!4,!3
!: A! !?,!8,!9

Tho doondonco of fho S!I! nnd IIQZ on fho ! InsfrucfIon monns fhnf n
sfnII wIII bo noodod nffor fho !. Suoso fhIs brnnch wns nImosf nIwnys fnkon nnd
fhnf fho vnIuo of !? wns nof noodod on fho fnII-fhrough nfh. Thon wo couId Incronso
fho sood of fho rogrnm by movIng fho InsfrucfIon A !?,!8,!9 fo fho osIfIon
nffor fho !. If fho brnnch wns rnroIy fnkon nnd fhnf fho vnIuo of !4 wns nof noodod on
fho fnkon nfh, fhon wo couId confomInfo movIng fho O! InsfrucfIon nffor fho !.
To orform fhoso ofImIznfIons, wo nood fo rodIcf fho brnnch sfnfIcnIIy whon
wo comIIo fho rogrnm. Thoro nro sovornI dIfforonf mofhods fo sfnfIcnIIy rodIcf
brnnch bohnvIor. Tho sImIosf schomo Is fo rodIcf n brnnch ns fnkon. ThIs schomo hns
nn nvorngo mIsrodIcfIon rnfo fhnf Is oqunI fo fho unfnkon brnnch froquoncy, whIch for
fho SIIC rogrnms Is 34. !nforfunnfoIy, fho mIsrodIcfIon rnfo rnngos from nof vory
nccurnfo (59) fo hIghIy nccurnfo (9).
A boffor nIfornnfIvo Is fo rodIcf on fho bnsIs of brnnch dIrocfIon, choosIng
bnckwnrd-goIng brnnchos fo bo fnkon nnd forwnrd-goIng brnnchos fo bo nof fnkon. Ior
somo rogrnms nnd comIInfIon sysfoms, fho froquoncy of forwnrd fnkon brnnchos mny
bo sIgnIfIcnnfIy Ioss fhnn 50, nnd fhIs schomo wIII do boffor fhnn jusf rodIcfIng nII
brnnchos ns fnkon. In fho SIIC rogrnms, howovor, moro fhnn hnIf of fho forwnrd-
goIng brnnchos nro fnkon.

Computev AvcLItectuve
TLunguveI Muvugun 150
Honco, rodIcfIng nII brnnchos ns fnkon Is fho boffor nronch. A sfIII moro
nccurnfo fochnIquo Is fo rodIcf brnnchos on fho bnsIs of rofIIo InformnfIon coIIocfod
from onrIIor runs. Tho koy obsorvnfIon fhnf mnkos fhIs worfhwhIIo Is fhnf fho bohnvIor
of brnnchos Is offon bImodnIIy dIsfrIbufod; fhnf Is, nn IndIvIdunI brnnch Is offon hIghIy
bInsod fownrd fnkon or unfnkon.

3.3 STATIC MUITIPI ISSU : TH VIIW APPROACH
Tho comIIor mny bo roquIrod fo onsuro fhnf doondoncos wIfhIn fho Issuo
nckof cnnnof bo rosonf or, nf n mInImum, IndIcnfo whon doondonco mny bo rosonf.
Tho fIrsf muIfIIo-Issuo rocossors fhnf roquIrod fho InsfrucfIon sfronm fo bo oxIIcIfIy
orgnnIzod fo nvoId doondoncos.
ThIs nrchIfocfurnI nronch wns nnmod V!IW, sfnndIng for Vory !ong
InsfrucfIon Word, nnd donofIng fhnf fho InsfrucfIons, sInco fhoy confnInod sovornI
InsfrucfIons, woro vory wIdo (64 fo l28 bIfs, or moro). Tho bnsIc nrchIfocfurnI concofs
nnd comIIor fochnoIogy nro fho snmo whofhor muIfIIo oornfIons nro orgnnIzod Info n
sIngIo InsfrucfIon, or whofhor n sof of InsfrucfIons In nn Issuo nckof Is roconfIgurod
by n comIIor fo oxcIudo doondonf oornfIons (sInco fho Issuo nckof cnn bo fhoughf of
ns n vory Inrgo InsfrucfIon). InrIy V!IWs woro quIfo rIgId In fhoIr InsfrucfIon formnfs
nnd offocfIvoIy roquIrod rocomIInfIon of rogrnms for dIfforonf vorsIons of fho
hnrdwnro.

TLe BusIc VIIW AppvoucL
V!IWs uso muIfIIo, Indoondonf funcfIonnI unIfs. !nfhor fhnn nffomfIng fo
Issuo muIfIIo, Indoondonf InsfrucfIons fo fho unIfs, n V!IW nckngos fho muIfIIo
oornfIons Info ono vory Iong InsfrucfIon, or roquIros fhnf fho InsfrucfIons In fho Issuo
nckof snfIsfy fho snmo consfrnInfs. wo wIII nssumo fhnf muIfIIo oornfIons nro Incod
In ono InsfrucfIon, ns In fho orIgInnI V!IW nronch. SInco fho burdon for choosIng fho
InsfrucfIons fo bo Issuod sImuIfnnoousIy fnIIs on fho comIIor, fho hnrdwnro In n
suorscnInr fo mnko fhoso Issuo docIsIons Is unnoodod.

Computev AvcLItectuve
TLunguveI Muvugun 151
SInco fhIs ndvnnfngo of n V!IW Incronsos ns fho mnxImum Issuo rnfo grows, wo
focus on n wIdor-Issuo rocossor. Indood, for sImIo fwo Issuo rocossors, fho ovorhond
of n suorscnInr Is robnbIy mInImnI. Iocnuso V!IW nronchos mnko sonso for wIdor
rocossors, wo chooso fo focus our oxnmIo on such nn nrchIfocfuro.
Ior oxnmIo, n V!IW rocossor mIghf hnvo InsfrucfIons fhnf confnIn fIvo
oornfIons, IncIudIng: ono Infogor oornfIon (whIch couId nIso bo n brnnch), fwo
fIonfIng-oInf oornfIons, nnd fwo momory roforoncos. Tho InsfrucfIon wouId hnvo n sof
of fIoIds for onch funcfIonnI unIf orhns l6 fo 24 bIfs or unIf, yIoIdIng nn
InsfrucfIon Iongfh of bofwoon ll2 nnd l68 bIfs.
To koo fho funcfIonnI unIfs busy, fhoro musf bo onough nrnIIoIIsm In n codo
soquonco fo fIII fho nvnIInbIo oornfIon sIofs. ThIs nrnIIoIIsm Is uncovorod by unroIIIng
Ioos nnd schoduIIng fho codo wIfhIn fho sIngIo Inrgor Ioo body. If fho unroIIIng
gonornfos sfrnIghIIno codo, fhon locol ecIeJuling fochnIquos, whIch oornfo on n sIngIo
bnsIc bIock cnn bo usod.
If fIndIng nnd oxIoIfIng fho nrnIIoIIsm roquIros schoduIIng codo ncross
brnnchos, n subsfnnfInIIy moro comIox gloIol ecIeJuling nIgorIfhm musf bo usod.
CIobnI schoduIIng nIgorIfhms nro nof onIy moro comIox In sfrucfuro, buf fhoy musf
donI wIfh sIgnIfIcnnfIy moro comIIcnfod frndooffs In ofImIznfIon, sInco movIng codo
ncross brnnchos Is oxonsIvo. Troce ecIeJuling ie ono of fhoso gIobnI schoduIIng
fochnIquos dovoIood socIfIcnIIy for V!IWs.
Suoso wo hnvo n V!IW fhnf couId Issuo fwo momory roforoncos, fwo II
oornfIons, nnd ono Infogor oornfIon or brnnch In ovory cIock cycIo. Show nn unroIIod
vorsIon of fho Ioo x|I] = x|I] +s for such n rocossor. !nroII ns mnny fImos ns nocossnry
fo oIImInnfo nny sfnIIs. Ignoro fho brnnch-doIny sIof.
Tho codo Is shown In IIguro. Tho Ioo hns boon unroIIod fo mnko sovon coIos of
fho body, whIch oIImInnfos nII sfnIIs (I.o., comIofoIy omfy Issuo cycIos), nnd runs In 9
cycIos. ThIs codo yIoIds n runnIng rnfo of sovon rosuIfs In 9 cycIos, or l.29 cycIos or
rosuIf, nonrIy fwIco ns fnsf ns fho fwo-Issuo suorscnInr fhnf usod unroIIod nnd
schoduIod codo. Ior fho orIgInnI V!IW modoI, fhoro nro bofh fochnIcnI nnd IogIsfIcnI
robIoms. Tho fochnIcnI robIoms nro fho Incronso In codo sIzo nnd fho IImIfnfIons of
Iock-sfo oornfIon.
Computev AvcLItectuve
TLunguveI Muvugun 152
Two dIfforonf oIomonfs combIno fo Incronso codo sIzo subsfnnfInIIy for n V!IW.
IIrsf, gonornfIng onough oornfIons In n sfrnIghf-IIno codo frngmonf roquIros
nmbIfIousIy unroIIIng Ioos (ns onrIIor oxnmIos) fhoroby IncronsIng codo sIzo. Socond,
whonovor InsfrucfIons nro nof fuII, fho unusod funcfIonnI unIfs frnnsInfo fo wnsfod bIfs
In fho InsfrucfIon oncodIng.


VIIW InstvuctIons tLut occupy tLe Innev Ioop und vepIuce tLe unvoIIed
sequence.

In IIguro, wo snw fhnf onIy nbouf 60 of fho funcfIonnI unIfs woro usod, so
nImosf hnIf of onch InsfrucfIon wns omfy. In mosf V!IWs, nn InsfrucfIon mny nood fo
bo Ioff comIofoIy omfy If no oornfIons cnn bo schoduIod.
Computev AvcLItectuve
TLunguveI Muvugun 153
InrIy V!IWs oornfod In Iock-sfo; fhoro wns no hnznrd dofocfIon hnrdwnro nf
nII. ThIs sfrucfuro dIcfnfod fhnf n sfnII In nny funcfIonnI unIf IoIIno musf cnuso fho
onfIro rocossor fo sfnII, sInco nII fho funcfIonnI unIfs musf bo kof synchronIzod.
AIfhough n comIIor mny bo nbIo fo schoduIo fho doformInIsfIc funcfIonnI unIfs fo
rovonf sfnIIs, rodIcfIng whIch dnfn nccossos wIII oncounfor n cncho sfnII nnd
schoduIIng fhom Is vory dIffIcuIf.
Honco, cnchos noodod fo bo bIockIng nnd fo cnuso oll fho funcfIonnI unIfs fo sfnII.
As fho Issuo rnfo nnd numbor of momory roforoncos bocomos Inrgo, fhIs synchronIznfIon
rosfrIcfIon bocomos unnccofnbIo. In moro roconf rocossors, fho funcfIonnI unIfs
oornfo moro IndoondonfIy, nnd fho comIIor Is usod fo nvoId hnznrds nf Issuo fImo,
whIIo hnrdwnro chocks nIIow for unsynchronIzod oxocufIon onco InsfrucfIons nro Issuod.
IInnry codo comnfIbIIIfy hns nIso boon n mnjor IogIsfIcnI robIom for V!IWs. In
n sfrIcf V!IW nronch, fho codo soquonco mnkos uso of bofh fho InsfrucfIon sof
dofInIfIon nnd fho dofnIIod IoIIno sfrucfuro, IncIudIng bofh funcfIonnI unIfs nnd fhoIr
InfoncIos.
Ono ossIbIo soIufIon fo fhIs mIgrnfIon robIom, nnd fho robIom of bInnry codo
comnfIbIIIfy In gonornI, Is objocf-codo frnnsInfIon or omuInfIon. ThIs fochnoIogy Is
dovoIoIng quIckIy nnd couId Iny n sIgnIfIcnnf roIo In fufuro mIgrnfIon schomos.
Anofhor nronch Is fo fomor fho sfrIcfnoss of fho nronch so fhnf bInnry
comnfIbIIIfy Is sfIII fonsIbIo. ThIs Infor nronch Is usod In fho IA-64 nrchIfocfuro.
Tho mnjor chnIIongo for nII muIfIIo-Issuo rocossors Is fo fry fo oxIoIf Inrgo
nmounfs of I!I. Whon fho nrnIIoIIsm comos from unroIIIng sImIo Ioos In II
rogrnms, fho orIgInnI Ioo robnbIy couId hnvo boon run offIcIonfIy on n vocfor
rocossor.

3.4 AVANC COMPIIR SUPPORT IOR XPOSING AN
XPIOITING IIP
Wo vIow fhIs mnforInI ns rovIdIng gonornI bnckground fhnf wIII onnbIo fho
rondor fo hnvo n bnsIc undorsfnndIng of fho comIIor fochnIquos usod fo oxIoIf I!I In
modorn comufors.
Computev AvcLItectuve
TLunguveI Muvugun 154
etectIng und nLuncIng Ioop-IeveI PuvuIIeIIsm
!oo-IovoI nrnIIoIIsm Is normnIIy nnnIyzod nf fho sourco IovoI or cIoso fo If,
whIIo mosf nnnIysIs of I!I Is dono onco InsfrucfIons hnvo boon gonornfod by fho
comIIor.
!oo-IovoI nnnIysIs InvoIvos doformInIng whnf doondoncos oxIsf nmong fho
oornnds In n Ioo ncross fho IfornfIons of fhnf Ioo. Ior now, wo wIII consIdor onIy dnfn
doondoncos, whIch nrIso whon nn oornnd Is wrIffon nf somo oInf nnd rond nf n Infor
oInf. nmo doondoncos nIso oxIsf nnd mny bo romovod by ronnmIng fochnIquos IIko
fhoso wo usod onrIIor.
Tho nnnIysIs of Ioo-IovoI nrnIIoIIsm focusos on doformInIng whofhor dnfn
nccossos In Infor IfornfIons nro doondonf on dnfn vnIuos roducod In onrIIor IfornfIons,
such n doondonco Is cnIIod n loop-corrieJ JepenJence.
Iov (I=l000; I>0; I=Il)
x|I] = x|I] + s;
In fhIs Ioo, fhoro Is n doondonco bofwoon fho fwo usos of x|I], buf fhIs
doondonco Is wIfhIn n sIngIo IfornfIon nnd Is nof Ioo-cnrrIod. Thoro Is n doondonco
bofwoon succossIvo usos of I In dIfforonf IfornfIons, whIch Is Ioo-cnrrIod, buf fhIs
doondonco InvoIvos nn InducfIon vnrInbIo nnd cnn bo onsIIy rocognIzod nnd oIImInnfod.
IIndIng Ioo-IovoI nrnIIoIIsm InvoIvos rocognIzIng sfrucfuros such ns Ioos,
nrrny roforoncos, nnd InducfIon vnrInbIo comufnfIons, fho comIIor cnn do fhIs
nnnIysIs moro onsIIy nf or nonr fho sourco IovoI, ns oosod fo fho mnchInocodo IovoI.
!of`s Iook nf n moro comIox oxnmIo.
IXAMI!I ConsIdor n Ioo IIko fhIs ono:
Iov (I=l; I<=l00; I=I+l)
{ A|I+l] = A|I] + C|I]; /* Sl */
I|I+l] = I|I] + A|I+l]; /* S2 */ }
Computev AvcLItectuve
TLunguveI Muvugun 155
Assumo fhnf A, I, nnd C nro dIsfIncf, nonovorInIng nrrnys. Whnf nro fho dnfn
doondoncos nmong fho sfnfomonfs Sl nnd S2 In fho Ioo`
TIere ore Iuo JifferenI JepenJencee.
l. Sl usos n vnIuo comufod by Sl In nn onrIIor IfornfIon, sInco IfornfIon I
comufos A|I+l], whIch Is rond In IfornfIon I+l. Tho snmo Is fruo of S2 for I|I] nnd
I|I+l].
2. S2 usos fho vnIuo, A|I+l], comufod by Sl In fho snmo IfornfIon.
Thoso fwo doondoncos nro dIfforonf nnd hnvo dIfforonf offocfs. To soo how fhoy
dIffor, Iof`s nssumo fhnf onIy ono of fhoso doondoncos oxIsfs nf n fImo. Iocnuso fho
doondonco of sfnfomonf Sl on nn onrIIor IfornfIon of Sl, fhIs doondonco Is Ioo-
cnrrIod. ThIs doondonco forcos succossIvo IfornfIons of fhIs Ioo fo oxocufo In sorIos.
Tho socond doondonco nbovo (S2 doondIng on Sl) Is wIfhIn nn IfornfIon nnd Is
nof Ioo-cnrrIod. Thus, If fhIs woro fho onIy doondonco, muIfIIo IfornfIons of fho Ioo
couId oxocufo In nrnIIoI, ns Iong ns onch nIr of sfnfomonfs In nn IfornfIon woro kof In
ordor.
If Is nIso ossIbIo fo hnvo n Ioo-cnrrIod doondonco fhnf doos nof rovonf
nrnIIoIIsm,ns fho noxf oxnmIo shows.
IXAMI!I ConsIdor n Ioo IIko fhIs ono:
Iov (I=l; I<=l00; I=I+l)
{
A|I] = A|I] + I|I]; /* Sl */
I|I+l] = C|I] + |I]; /* S2 */
}
Whnf nro fho doondoncos bofwoon Sl nnd S2` Is fhIs Ioo nrnIIoI` If nof, show
how fo mnko If nrnIIoI.
Computev AvcLItectuve
TLunguveI Muvugun 156
Sfnfomonf Sl usos fho vnIuo nssIgnod In fho rovIous IfornfIon by sfnfomonf S2,
so fhoro Is n Ioo-cnrrIod doondonco bofwoon S2 nnd Sl. osIfo fhIs Ioo-cnrrIod
doondonco, fhIs Ioo cnn bo mndo nrnIIoI. !nIIko fho onrIIor Ioo, fhIs doondonco Is
nof cIrcuInr: oIfhor sfnfomonf doonds on IfsoIf, nnd nIfhough Sl doonds on S2, S2
doos nof doond on Sl. A Ioo Is nrnIIoI If If cnn bo wrIffon wIfhouf n cycIo In fho
doondoncos, sInco fho nbsonco of n cycIo monns fhnf fho doondoncos gIvo n nrfInI
ordorIng on fho sfnfomonfs.
AIfhough fhoro nro no cIrcuInr doondoncos In fho nbovo Ioo, If musf bo
frnnsformod fo conform fo fho nrfInI ordorIng nnd oxoso fho nrnIIoIIsm. Two
obsorvnfIons nro crIfIcnI fo fhIs frnnsformnfIon:
l. Thoro Is no doondonco from Sl fo S2. If fhoro woro, fhon fhoro wouId bo
n cycIo In fho doondoncos nnd fho Ioo wouId nof bo nrnIIoI. SInco fhIs
ofhor doondonco Is nbsonf, InforchnngIng fho fwo sfnfomonfs wIII nof
nffocf fho oxocufIon of S2.
2. On fho fIrsf IfornfIon of fho Ioo, sfnfomonf Sl doonds on fho vnIuo of
I|l] comufod rIor fo InIfInfIng fho Ioo.
Thoso fwo obsorvnfIons nIIow us fo roInco fho Ioo nbovo wIfh fho foIIowIng codo
soquonco:
A|l] = A|l] + I|l];
Iov (I=l; I<=99; I=I+l)
{ I|I+l] = C|I] + |I];
A|I+l] = A|I+l] + I|I+l];
}
I|l0l] = C|l00] + |l00];
Computev AvcLItectuve
TLunguveI Muvugun 15?
Tho doondonco bofwoon fho fwo sfnfomonfs Is no Iongor Ioo-cnrrIod, so fhnf
IfornfIons of fho Ioo mny bo ovorInod, rovIdod fho sfnfomonfs In onch IfornfIon nro
kof In ordor.
!oo-cnrrIod doondoncos nro In fho form of n recurrence:
Iov (I=2;I<=l00;I=I+l)
{
Y|I] = Y|I-l] + Y|I];
}
A rocurronco Is whon n vnrInbIo Is dofInod bnsod on fho vnIuo of fhnf vnrInbIo In
nn onrIIor IfornfIon, offon fho ono ImmodInfoIy rocodIng, ns In fho nbovo frngmonf.
ofocfIng n rocurronco cnn bo Imorfnnf for fwo ronsons: Somo nrchIfocfuros (osocInIIy
vocfor comufors) hnvo socInI suorf for oxocufIng rocurroncos, nnd somo rocurroncos
cnn bo fho sourco of n ronsonnbIo nmounf of nrnIIoIIsm. To soo how fho Inffor cnn bo
fruo, consIdor fhIs Ioo:
Iov (I=6;I<=l00;I=I+l)
{
Y|I] = Y|I-5] + Y|I];
}
On fho IfornfIon i, fho Ioo roforoncos oIomonf i 5. Tho Ioo Is snId fo hnvo n
JepenJence JieIonce of 5. Mnny Ioos wIfh cnrrIod doondoncos hnvo n doondonco
dIsfnnco of l. Tho Inrgor fho dIsfnnco, fho moro ofonfInI nrnIIoIIsm cnn bo obfnInod by
unroIIIng fho Ioo.
Ior oxnmIo, If wo unroII fho fIrsf Ioo, wIfh n doondonco dIsfnnco of l,
succossIvo sfnfomonfs nro doondonf on ono nnofhor; fhoro Is sfIII somo nrnIIoIIsm
nmong fho IndIvIdunI InsfrucfIons, buf nof much.
Computev AvcLItectuve
TLunguveI Muvugun 15B
If wo unroII fho Ioo fhnf hns n doondonco dIsfnnco of 5, fhoro Is n soquonco of
fIvo sfnfomonfs fhnf hnvo no doondoncos, nnd fhus much moro I!I.
IIndIng ependences
IIndIng fho doondoncos In n rogrnm Is nn Imorfnnf nrf of fhroo fnsks:
(l) Cood schoduIIng of codo
(2) oformInIng whIch Ioos mIghf confnIn nrnIIoIIsm
(3) IIImInnfIng nnmo doondoncos.
Tho comIoxIfy of doondonco nnnIysIs nrIsos bocnuso of fho rosonco of nrrnys
nnd oInfors In Inngungos IIko C or C++ or nss-by-roforonco nrnmofor nssIng In
IO!T!A.
How doos fho comIIor dofocf doondoncos In gonornI` onrIy nII doondonco
nnnIysIs nIgorIfhms work on fho nssumfIon fhnf nrrny IndIcos nro offine. In sImIosf
forms, n ono-dImonsIonnI nrrny Indox Is nffIno If If cnn bo wrIffon In fho form o * i + I,
whoro o nnd I nro consfnnfs, nnd i Is fho Ioo Indox vnrInbIo. Tho Indox of n
muIfIdImonsIonnI nrrny Is nffIno If fho Indox In onch dImonsIon Is nffIno. Snrso nrrny
nccossos, whIch fyIcnIIy hnvo fho form x|y|I]], nro ono of fho mnjor oxnmIos of
nonnffIno nccossos.
oformInIng whofhor fhoro Is n doondonco bofwoon fwo roforoncos fo fho snmo
nrrny In n Ioo Is fhus oquIvnIonf fo doformInIng whofhor fwo nffIno funcfIons cnn hnvo
fho snmo vnIuo for dIfforonf IndIcos bofwoon fho bounds of fho Ioo. Ior oxnmIo,
suoso wo hnvo sforod fo nn nrrny oIomonf wIfh Indox vnIuo o * i + I nnd Iondod from
fho snmo nrrny wIfh Indox vnIuo c * i + J, whoro i Is fho for-Ioo Indox vnrInbIo fhnf
runs from n fo n.
A doondonco oxIsfs If fwo condIfIons hoId:
l. Thoro nro fwo IfornfIon IndIcos, j nnd l, bofh wIfhIn fho IImIfs of fho for Ioo.
Thnf Is n _ j _ n, n _ l _ n.
Computev AvcLItectuve
TLunguveI Muvugun 159
2. Tho Ioo sforos Info nn nrrny oIomonf Indoxod by o * j + I nnd Infor fofchos from
fhnf eone nrrny oIomonf whon If Is Indoxod by c* l + J. Thnf Is, o * j +I = c * l +
J.
A sImIo nnd suffIcIonf fosf for fho nbsonco of n doondonco Is fho greoIeeI
connon Jitieor, or CC, fosf. If Is bnsod on fho obsorvnfIon fhnf If n Ioo-cnrrIod
doondonco oxIsfs, fhon CC (c,o) musf JitiJe (J I).
XAMPI
!so fho CC fosf fo doformIno whofhor doondoncos oxIsf In fho foIIowIng Ioo:
Iov (I=l; I<=l00; I=I+l)
{
X|2*I+3] = X|2*I] * 5.0;
}
CIvon fho vnIuos o = 2, I = 3, c = 2, nnd J = 0, fhon CC (o ,c) = 2, nnd J I =
3. SInco 2 do nof dIvIdo 3, no doondonco Is ossIbIo.Tho CC fosf Is suffIcIonf fo
gunrnnfoo fhnf no doondonco oxIsfs; howovor, fhoro nro cnsos whoro fho CC fosf
succoods buf no doondonco oxIsfs. ThIs cnn nrIso, for oxnmIo, bocnuso fho CC fosf
doos nof fnko fho Ioo bounds Info nccounf.
In gonornI, doformInIng whofhor n doondonco ncfunIIy oxIsfs Is I-comIofo. In
rncfIco, howovor, mnny common cnsos cnn bo nnnIyzod rocIsoIy nf Iow cosf. !oconfIy,
nronchos usIng n hIornrchy of oxncf fosfs IncronsIng In gonornIIfy nnd cosf hnvo boon
shown fo bo bofh nccurnfo nnd offIcIonf.
In nddIfIon fo dofocfIng fho rosonco of n doondonco, n comIIor wnnfs fo
cInssIfy fho fyo of doondonco. ThIs cInssIfIcnfIon nIIows n comIIor fo rocognIzo nnmo
doondoncos nnd oIImInnfo fhom nf comIIo fImo by ronnmIng nnd coyIng.
Computev AvcLItectuve
TLunguveI Muvugun 160
Tho foIIowIng Ioo hns muIfIIo fyos of doondoncos. IInd nII fho fruo
doondoncos, oufuf doondoncos, nnd nnfIdoondoncos, nnd oIImInnfo fho oufuf
doondoncos nnd nnfIdoondoncos by ronnmIng.
Iov (I=l; I<=l00; I=I+l)
{
Y|I] = X|I] / c; /*Sl*/
X|I] = X|I] + c; /*S2*/
Z|I] = Y|I] + c; /*S3*/
Y|I] = c - Y|I]; /*S4*/
}
Tho foIIowIng doondoncos oxIsf nmong fho four sfnfomonfs:
l. Thoro nro fruo doondoncos from Sl fo S3 nnd from Sl fo S4 bocnuso of Y|I].
Thoso nro nof Ioo cnrrIod, so fhoy do nof rovonf fho Ioo from boIng consIdorod
nrnIIoI. Thoso doondoncos wIII
forco S3 nnd S4 fo wnIf for Sl fo comIofo.
2. Thoro Is nn nnfIdoondonco from Sl fo S2, bnsod on X|I].
3. Thoro Is nn nnfIdoondonco from S3 fo S4 for Y|I].
4. Thoro Is nn oufuf doondonco from Sl fo S4, bnsod on Y|I].
Tho foIIowIng vorsIon of fho Ioo oIImInnfos fhoso fnIso (or soudo) doondoncos.
Iov (I=l; I<=l00; I=I+l
{
/* Y ronnmod fo T fo romovo oufuf doondonco*/
Computev AvcLItectuve
TLunguveI Muvugun 161
T|I] = X|I] / c;
/* X ronnmod fo Xl fo romovo nnfIdoondonco*/
Xl|I] = X|I] + c;
/* Y ronnmod fo T fo romovo nnfIdoondonco */
Z|I] = T|I] + c;
Y|I] = c - T|I];
}
Affor fho Ioo fho vnrInbIo X hns boon ronnmod Xl. In codo fhnf foIIows fho Ioo,
fho comIIor cnn sImIy roInco fho nnmo X by Xl. In fhIs cnso, ronnmIng doos nof
roquIro nn ncfunI coy oornfIon buf cnn bo dono by subsfIfufIng nnmos or by rogIsfor
nIIocnfIon. In ofhor cnsos, howovor, ronnmIng wIII roquIro coyIng.
oondonco nnnIysIs Is n crIfIcnI fochnoIogy for oxIoIfIng nrnIIoIIsm. Af fho
InsfrucfIon IovoI If rovIdos InformnfIon noodod fo Inforchnngo momory roforoncos
whon schoduIIng, ns woII ns fo doformIno fho bonofIfs of unroIIIng n Ioo. Ior dofocfIng
Ioo-IovoI nrnIIoIIsm, doondonco nnnIysIs Is fho bnsIc fooI. IffocfIvoIy comIIIng
rogrnms fo oIfhor vocfor comufors or muIfIrocossors doonds crIfIcnIIy on fhIs
nnnIysIs. Tho mnjor drnwbnck of doondonco nnnIysIs Is fhnf If nIIos onIy undor n
IImIfod sof of cIrcumsfnncos, nnmoIy nmong roforoncos wIfhIn n sIngIo Ioo nosf nnd
usIng nffIno Indox funcfIons.
Thus, fhoro nro n wIdo vnrIofy of sIfunfIons In whIch nrrny-orIonfod doondonco
nnnIysIs connoI foII us whnf wo mIghf wnnf fo know, IncIudIng fho foIIowIng:
Whon objocfs nro roforoncod vIn oInfors rnfhor fhnn nrrny IndIcos
whon nrrny IndoxIng Is IndIrocf fhrough nnofhor nrrny, whIch hnons wIfh
mnny rorosonfnfIons of snrso nrrnys
whon n doondonco mny oxIsf for somo vnIuo of fho Inufs, buf doos nof oxIsf In
ncfunIIfy whon fho codo Is run sInco fho Inufs novor fnko on fhoso vnIuos
Computev AvcLItectuve
TLunguveI Muvugun 162
Whon nn ofImIznfIon doonds on knowIng moro fhnn jusf fho ossIbIIIfy of
doondonco, buf noods fo know on uIicI wrIfo of n vnrInbIo n rond of fhnf
vnrInbIo doonds.
To donI wIfh fho Issuo of nnnIyzIng rogrnms wIfh oInfors, nnofhor fyo of
nnnIysIs, offon cnIIod poinIe-Io nnnIysIs, Is roquIrod. Tho koy quosfIon fhnf wo wnnf
nnsworod from doondonco nnnIysIs of oInfors Is whofhor fwo oInfors cnn dosIgnnfo
fho snmo nddross. In fho cnso of comIox dynnmIc dnfn sfrucfuros, fhIs robIom Is
oxfromoIy dIffIcuIf.
Tho bnsIc nronch usod In oInfs-fo nnnIysIs roIIos on InformnfIon from fhroo mnjor
sourcos:
l. Tyo InformnfIon, whIch rosfrIcfs whnf n oInfor cnn oInf fo.
2. InformnfIon dorIvod whon nn objocf Is nIIocnfod or whon fho nddross of nn objocf
Is fnkon, whIch cnn bo usod fo rosfrIcf whnf n oInfor cnn oInf fo. Ior oxnmIo,
If nIwnys oInfs fo nn objocf nIIocnfod In n gIvon sourco IIno nnd q novor oInfs
fo fhnf objocf, fhon nnd q cnn novor oInf fo fho snmo objocf.
3. InformnfIon dorIvod from oInfor nssIgnmonfs. Ior oxnmIo, If mny bo
nssIgnod fho vnIuo of q, fhon mny oInf fo nnyfhIng q oInfs fo.
Thoro nro sovornI cnsos whoro nnnIyzIng oInfors hns boon succossfuIIy nIIod nnd
Is oxfromoIy usofuI:
Whon oInfors nro usod fo nss fho nddross of nn objocf ns n nrnmofor, If Is
ossIbIo fo uso oInfs-fo nnnIysIs fo doformIno fho ossIbIo sof of objocfs
roforoncodby n oInfor. Ono Imorfnnf uso Is fo doformIno If fwo oInfor
nrnmoforsmny dosIgnnfo fho snmo objocf.
Whon n oInfor cnn oInf fo ono of sovornI fyos, If Is somofImos ossIbIo fo
doformIno fhnf fho fyo of fho dnfn objocf n oInfor dosIgnnfos nf dIfforonf nrfs
of fho rogrnm.
If Is offon ossIbIo fo sonrnfo ouf oInfors fhnf mny onIy oInf fo n IocnI objocf
vorsus n gIobnI ono.
Computev AvcLItectuve
TLunguveI Muvugun 163
Thoro nro fwo dIfforonf fyos of IImIfnfIons fhnf nffocf our nbIIIfy fo do nccurnfo
doondonco nnnIysIs for Inrgo rogrnms. Tho fIrsf fyo of IImIfnfIon nrIsos from
rosfrIcfIons In fho nnnIysIs nIgorIfhms. Tho socond IImIfnfIon Is fho nood fo nnnIyzo
bohnvIor ncross rocoduro boundnrIos fo gof nccurnfo InformnfIon.
IImInutIng ependent CompututIons
ComIIors cnn roduco fho Imncf of doondonf comufnfIons so ns fo nchIovo
moro I!I. Tho koy fochnIquo Is fo oIImInnfo or roduco n doondonf comufnfIon by bnck
subsfIfufIon, whIch Incronsos fho nmounf of nrnIIoIIsm nnd somofImos Incronsos fho
nmounf of comufnfIon roquIrod. Thoso fochnIquos cnn bo nIIod bofh wIfhIn n bnsIc
bIock nnd wIfhIn Ioos, nnd wo doscrIbo fhom dIfforonfIy.
WIfhIn n bnsIc bIock, nIgobrnIc sImIIfIcnfIons of oxrossIons nnd nn ofImIznfIon
cnIIod cop, propogoIion, whIch oIImInnfos oornfIons fhnf coy vnIuos, cnn bo usod fo
sImIIfy soquoncos IIko fho foIIowIng:
A!I !l,!2,#4 A!I !l,!l,#4
fo: A!I !l,!2,#8
In fhoso oxnmIos, comufnfIons nro ncfunIIy oIImInnfod, buf If nIso ossIbIo
fhnf wo mny wnnf fo Incronso fho nrnIIoIIsm of fho codo, ossIbIy ovon IncronsIng fho
numbor of oornfIons. Such ofImIznfIons nro cnIIod Iree IeigII reJucIion, sInco fhoy
roduco fho hoIghf of fho froo sfrucfuro rorosonfIng n comufnfIon, mnkIng If wIdor buf
shorfor. ConsIdor fho foIIowIng codo soquonco:
A !l,!2,!3
A !4,!l,!6
A !8,!4,!?
ofIco fhnf fhIs soquonco roquIros nf Ionsf fhroo oxocufIon cycIos, sInco nII fho
InsfrucfIons doond on fho ImmodInfo rodocossor. Iy fnkIng ndvnnfngo of
nssocInfIvIfy, wo cnn frnnsform fho codo nnd rowrIfo If ns:
Computev AvcLItectuve
TLunguveI Muvugun 164

A !l,!2,!3
A !4,!6,!?
A !8,!l,!4
ThIs soquonco cnn bo comufod In fwo oxocufIon cycIos.
Iecurrencee nro oxrossIons whoso vnIuo on ono IfornfIon Is gIvon by n funcfIon
fhnf doonds on fho rovIous IfornfIons. Whon n Ioo wIfh n rocurronco Is unroIIod, wo
mny bo nbIo fo nIgobrnIcnIIy ofImIzo fho unroIIod Ioo, so fhnf fho rocurronco nood onIy
bo ovnIunfod onco or unroIIod IfornfIon. Ono common fyo of rocurronco nrIsos from nn
oxIIcIf rogrnm sfnfomonfs, such ns:
sum = sum + x;
Assumo wo unroII n Ioo wIfh fhIs rocurronco fIvo fImos, If wo Iof fho vnIuo of x
on fhoso fIvo IfornfIons bo gIvon by xl, x2, x3, x4, nnd x5, fhon wo cnn wrIfo fho vnIuo of
sum nf fho ond of onch unroII ns:
sum = sum + xl + x2 + x3 + x4 + x5;
If unofImIzod fhIs oxrossIon roquIros fIvo doondonf oornfIons, buf If cnn bo
rowrIffon ns:
sum = ((sum + xl) + (x2 + x3)) + (x4 + x5);
whIch cnn bo ovnIunfod In onIy fhroo doondonf oornfIons.
!ocurroncos nIso nrIso from ImIIcIf cnIcuInfIons, such ns fhoso nssocInfod wIfh
nrrny IndoxIng. Inch nrrny Indox frnnsInfos fo nn nddross fhnf Is comufod bnsod on
fho Ioo Indox vnrInbIo. AgnIn, wIfh unroIIIng nnd nIgobrnIc ofImIznfIon, fho
doondonf comufnfIons cnn bo mInImIzod.

Computev AvcLItectuve
TLunguveI Muvugun 165
SoItwuve PIpeIInIng: SymboIIc Ioop UnvoIIIng
SofIuore pipelining Is n fochnIquo for roorgnnIzIng Ioos such fhnf onch IfornfIon
In fho soffwnro-IoIInod codo Is mndo from InsfrucfIons choson from dIfforonf
IfornfIons of fho orIgInnI Ioo. ThIs nronch Is mosf onsIIy undorsfood by IookIng nf fho
schoduIod codo for fho suorscnInr vorsIon of MIIS, whIch nonrod.
Tho schoduIor In fhIs oxnmIo ossonfInIIy InforIonvos InsfrucfIons from dIfforonf
Ioo IfornfIons, so ns fo sonrnfo fho doondonf InsfrucfIons fhnf occur wIfhIn n sIngIo
Ioo IfornfIon. Iy choosIng InsfrucfIons from dIfforonf IfornfIons, doondonf
comufnfIons nro sonrnfod from ono nnofhor by nn onfIro Ioo body, IncronsIng fho
ossIbIIIfy fhnf fho unroIIod Ioo cnn bo schoduIod wIfhouf sfnIIs.
A soffwnro-IoIInod Ioo InforIonvos InsfrucfIons from dIfforonf IfornfIons
wIfhouf unroIIIng fho Ioo, ns IIIusfrnfod In IIguro. ThIs fochnIquo Is fho soffwnro
counfornrf fo whnf TomnsuIo`s nIgorIfhm doos In hnrdwnro. Tho soffwnroIoIInod
Ioo for fho onrIIor oxnmIo wouId confnIn ono Iond, ono ndd, nnd ono sforo, onch from n
dIfforonf IfornfIon. Thoro Is nIso somo sfnrf-u codo fhnf Is noodod boforo fho Ioo
bogIns ns woII ns codo fo fInIsh u nffor fho Ioo Is comIofod.

A soItwuve-pIpeIIned Ioop cLooses InstvuctIons Ivom dIIIevent Ioop ItevutIons,
tLus sepuvutIng tLe dependent InstvuctIons wItLIn one ItevutIon oI tLe
ovIgInuI Ioop.
Computev AvcLItectuve
TLunguveI Muvugun 166
!ogIsfor mnnngomonf In soffwnro-IoIInod Ioos cnn bo frIcky. Tho oxnmIo
nbovo Is nof foo hnrd sInco fho rogIsfors fhnf nro wrIffon on ono Ioo IfornfIon nro rond
on fho noxf. In ofhor cnsos, wo mny nood fo Incronso fho numbor of IfornfIons bofwoon
whon wo Issuo nn InsfrucfIon nnd whon fho rosuIf Is usod.
ThIs Incronso Is roquIrod whon fhoro nro n smnII numbor of InsfrucfIons In fho
Ioo body nnd fho InfoncIos nro Inrgo. In such cnsos, n combInnfIon of soffwnro
IoIInIng nnd Ioo unroIIIng Is noodod. An oxnmIo of fhIs Is shown In fho IxorcIsos.
Soffwnro IoIInIng cnn bo fhoughf of ns e,nIolic Ioo unroIIIng. Indood, somo of
fho nIgorIfhms for soffwnro IoIInIng uso Ioo-unroIIIng nIgorIfhms fo fIguro ouf how
fo soffwnro IoIIno fho Ioo.
Tho mnjor ndvnnfngo of soffwnro IoIInIng ovor sfrnIghf Ioo unroIIIng Is fhnf
soffwnro IoIInIng consumos Ioss codo snco.
Soffwnro IoIInIng roducos fho fImo whon fho Ioo Is nof runnIng nf onk sood
fo onco or Ioo nf fho bogInnIng nnd ond.
If wo unroII n Ioo fhnf doos l00 IfornfIons n consfnnf numbor of fImos, sny 4, wo
ny fho ovorhond l00/4 = 25 fImos ovory fImo fho Innor unroIIod Ioo Is InIfInfod.

TLe eecutIon puttevn Iov (u) u soItwuve-pIpeIIned Ioop und (b) un unvoIIed
Ioop.

Computev AvcLItectuve
TLunguveI Muvugun 16?
GIobuI Code ScLeduIIng
Soffwnro IoIInIng works woII whon fho body Is sIngIo bnsIc bIock, sInco If Is
onsIor fo fInd fho roonfnbIo schoduIo. Whon fho body of nn unroIIod Ioo confnIns
InfornnI confroI fIow, howovor, schoduIIng fho codo Is much moro comIox. In gonornI,
offocfIvo schoduIIng of n Ioo body wIfh InfornnI confroI fIow wIII roquIro movIng
InsfrucfIons ncross brnnchos, whIch Is gIobnI codo schoduIIng. In fhIs socfIon, wo fIrsf
oxnmIno fho chnIIongo nnd IImIfnfIons of gIobnI codo schoduIIng.
CIobnI codo schoduIIng nIms fo comncf n codo frngmonf wIfh InfornnI confroI
sfrucfuro Info fho shorfosf ossIbIo soquonco fhnf rosorvos fho dnfn nnd confroI
doondoncos. Tho dnfn doondoncos forco n nrfInI ordor on oornfIons, whIIo fho
confroI doondoncos dIcfnfo InsfrucfIons ncross whIch codo cnnnof bo onsIIy movod.
nfn doondoncos nro ovorcomo by unroIIIng nnd, In fho cnso of momory oornfIons,
usIng doondonco nnnIysIs fo doformIno If fwo roforoncos rofor fo fho snmo nddross.
ConfroI doondoncos nrIsIng from Ioo brnnchos nro roducod by unroIIIng. CIobnI
codo schoduIIng cnn roduco fho offocf of confroI doondoncos nrIsIng from condIfIonnI
nonIoo brnnchos by movIng codo.CIobnI codo mofIon Is Imorfnnf sInco mnny Innor
Ioos confnIn condIfIonnI sfnfomonfs.

A code Ivugment und tLe common putL sLuded wItL gvuy.

Computev AvcLItectuve
TLunguveI Muvugun 16B
IIguro shows n fyIcnI codo frngmonf, whIch mny bo fhoughf of ns nn IfornfIon of
nn unroIIod Ioo nnd hIghIIghfs fho moro common confroIfIow. IffocfIvoIy schoduIIng
fhIs codo couId roquIro fhnf wo movo fho nssIgnmonfs fo I nnd C fo onrIIor In fho
oxocufIon soquonco, boforo fho fosf of A. Such gIobnI codo mofIon musf snfIsfy n sof of
consfrnInfs fo bo IognI. To orform fho movomonf of I, wo musf onsuro fhnf noIfhor fho
dnfn fIow nor fho oxcofIon bohnvIor Is chnngod. ComIIors nvoId chnngIng fho
oxcofIon bohnvIor by nof movIng corfnIn cInssos of InsfrucfIons, such ns momory
roforoncos, fhnf cnn cnuso oxcofIons.
ConsIdor fho fncfors fhnf fho comIIor wouId hnvo fo consIdor In movIng fho
comufnfIon nnd nssIgnmonf of I:
Whnf nro fho roInfIvo oxocufIon froquoncIos of fho fhon-cnso nnd fho oIso-cnso In
fho brnnch` If fho fhon-cnso Is much moro froquonf, fho codo mofIon mny bo
bonofIcInI. If nof, If Is Ioss IIkoIy, nIfhough nof ImossIbIo fo consIdor movIng fho
codo.
Whnf Is fho cosf of oxocufIng fho comufnfIon nnd nssIgnmonf fo I nbovo fho
brnnch` If mny bo fhnf fhoro nro n numbor of omfy InsfrucfIon Issuo sIofs In fho
codo nbovo fho brnnch nnd fhnf fho InsfrucfIons for I cnn bo Incod Info fhoso
sIofs fhnf wouId ofhorwIso go omfy. ThIs oorfunIfy mnkos fho comufnfIon of
I froo nf Ionsf fo fIrsf ordor.
How wIII fho movomonf of I chnngo fho oxocufIon fImo for fho fhon-cnso` If I Is
nf fho sfnrf of fho crIfIcnI nfh for fho fhon-cnso, movIng If mny bo hIghIy
bonofIcInI.
Is I fho bosf codo frngmonf fhnf cnn bo movod nbovo fho brnnch` How doos If
comnro wIfh movIng C or ofhor sfnfomonfs wIfhIn fho fhon-cnso`
Whnf Is fho cosf of fho comonsnfIon codo fhnf mny bo nocossnry for fho oIso
cnso` How offocfIvoIy cnn fhIs codo bo schoduIod nnd whnf Is Ifs Imncf on
oxocufIon fImo`
As wo cnn soo from fhIs porIiol IIsf, gIobnI codo schoduIIng Is nn oxfromoIy
comIox robIom. Tho frndooffs doond on mnny fncfors nnd IndIvIdunI docIsIons fo
gIobnIIy schoduIo InsfrucfIons nro hIghIy Infordoondonf.
Computev AvcLItectuve
TLunguveI Muvugun 169

Tvuce ScLeduIIng: IocusIng on tLe CvItIcuI PutL
Trnco schoduIIng Is usofuI for rocossors wIfh n Inrgo numbor of Issuos or cIock,
whoro condIfIonnI or rodIcnfod oxocufIon Is InnrorInfo or unsuorfod, nnd whoro
sImIo Ioo unroIIIng mny nof bo suffIcIonf by IfsoIf fo uncovor onough I!I fo koo fho
rocossor busy.
Trnco schoduIIng Is n wny fo orgnnIzo fho gIobnI codo mofIon rocoss, so ns fo
sImIIfy fho codo schoduIIng by IncurrIng fho cosfs of ossIbIo codo mofIon on fho Ioss
froquonf nfhs.
Thoro nro fwo sfos fo frnco schoduIIng. Tho fIrsf sfo, cnIIod Iroce eelecIion, frIos
fo fInd n IIkoIy soquonco of bnsIc bIocks whoso oornfIons wIII bo uf fogofhor Info n
smnIIor numbor of InsfrucfIons; fhIs soquonco Is cnIIod n Iroce.
!oo unroIIIng Is usod fo gonornfo Iong frncos, sInco Ioo brnnchos nro fnkon
wIfh hIgh robnbIIIfy. AddIfIonnIIy, by usIng sfnfIc brnnch rodIcfIon, ofhor condIfIonnI
brnnchos nro nIso choson ns fnkon or nof fnkon, so fhnf fho rosuIfnnf frnco Is n sfrnIghf-
IIno soquonco rosuIfIng from concnfonnfIng mnny bnsIc bIocks.
Onco n frnco Is soIocfod, fho socond rocoss, cnIIod Iroce conpocIion, frIos fo
squoozo fho frnco Info n smnII numbor of wIdo InsfrucfIons. Trnco comncfIon Is codo
schoduIIng; honco, If nffomfs fo movo oornfIons ns onrIy ns If cnn In n soquonco
(frnco), nckIng fho oornfIons Info ns fow wIdo InsfrucfIons (or Issuo nckofs) ns
ossIbIo.
Tho ndvnnfngo of fho frnco schoduIIng nronch Is fhnf If sImIIfIos fho docIsIons
concornIng gIobnI codo mofIon. In nrfIcuInr, brnnchos nro vIowod ns jums Info or ouf
of fho soIocfod frnco, whIch Is nssumod fo fho mosf robnbIo nfh.

Computev AvcLItectuve
TLunguveI Muvugun 1?0

TLIs tvuce Is obtuIned by ussumIng tLut tLe pvogvum Ivugment


Computev AvcLItectuve
TLunguveI Muvugun 1?1

SupevbIocks
Ono of fho mnjor drnwbncks of frnco schoduIIng Is fhnf fho onfrIos nnd oxIfs Info
fho mIddIo of fho frnco cnuso sIgnIfIcnnf comIIcnfIons roquIrIng fho comIIor fo
gonornfo nnd frnck fho comonsnfIon codo nnd offon mnkIng If dIffIcuIf fo nssoss fho
cosf of such codo. SuperIlocle nro formod by n rocoss sImIInr fo fhnf usod for frncos,
buf, nro n form of oxfondod bnsIc bIocks, whIch nro rosfrIcfod fo hnvo n sIngIo onfry
oInf buf nIIow muIfIIo oxIfs.

Tho suorbIock nronch roducos fho comIoxIfy of bookkooIng nnd schoduIIng
vorsus fho moro gonornI frnco gonornfIon nronch, buf mny onInrgo codo sIzo moro
fhnn n frnco-bnsod nronch. !Iko frnco schoduIIng, suorbIock schoduIIng my bo mosf
nrorInfo whon ofhor fochnIquos (If-convorsIon, o.g.) fnII.

Ivon In such cnsos, nssossIng fho cosf of codo duIIcnfIon mny IImIf fho
usofuInoss of fho nronch nnd wIII corfnInIy comIIcnfo fho comIInfIon rocoss.

!oo unroIIIng, soffwnro IoIInIng, frnco schoduIIng, nnd suorbIock schoduIIng
nII nIm nf fryIng fo Incronso fho nmounf of I!I fhnf cnn bo oxIoIfod by n rocossor
IssuIng moro fhnn ono InsfrucfIon on ovory cIock cycIo. Tho offocfIvonoss of onch of
fhoso fochnIquos nnd fhoIr suIfnbIIIfy for vnrIous nrchIfocfurnI nronchos nro nmong
fho hoffosf foIcs boIng ncfIvoIy ursuod by rosonrchors nnd dosIgnors of hIgh-sood
rocossors.



Computev AvcLItectuve
TLunguveI Muvugun 1?2

TLIs supevbIock vesuIts Ivom unvoIIIng tLe code Iouv tImes und cveutIng u
supevbIock.


Computev AvcLItectuve
TLunguveI Muvugun 1?3
3.5 HARWAR SUPPORT IOR XPOSING MOR PARAIIIISM AT
COMPIIR TIM
TochnIquos such ns Ioo unroIIIng, soffwnro IoIInIng, nnd frnco schoduIIng cnn
bo usod fo Incronso fho nmounf of nrnIIoIIsm nvnIInbIo whon fho bohnvIor of brnnchos
Is fnIrIy rodIcfnbIo nf comIIo fImo. Whon fho bohnvIor of brnnchos Is nof woII known,
comIIor fochnIquos nIono mny nof bo nbIo fo uncovor much I!I. In such cnsos, fho
confroI doondoncos mny sovoroIy IImIf fho nmounf of nrnIIoIIsm fhnf cnn bo oxIoIfod.
SImIInrIy, ofonfInI doondoncos bofwoon momory roforonco InsfrucfIons couId rovonf
codo movomonf fhnf wouId Incronso nvnIInbIo I!I. ThIs socfIon Infroducos sovornI
fochnIquos fhnf cnn hoI ovorcomo such IImIfnfIons.
Tho fIrsf Is nn oxfonsIon of fho InsfrucfIon sof fo IncIudo conJiIionol or
preJicoIeJ ineIrucIione. Such InsfrucfIons cnn bo usod fo oIImInnfo brnnchos convorfIng
n confroI doondonco Info n dnfn doondonco nnd ofonfInIIy ImrovIng orformnnco.
Hnrdwnro socuInfIon wIfh In-ordor commIf rosorvod oxcofIon bohnvIor by
dofocfIng nnd rnIsIng oxcofIons onIy nf commIf fImo whon fho InsfrucfIon wns no
Iongor socuInfIvo. To onhnnco fho nbIIIfy of fho conpiler fo socuInfIvoIy movo codo
ovor brnnchos, whIIo sfIII rosorvIng fho oxcofIon bohnvIor, wo consIdor sovornI
dIfforonf mofhods, whIch oIfhor IncIudo oxIIcIf chocks for oxcofIons or fochnIquos fo
onsuro fhnf onIy fhoso oxcofIons fhnf shouId nrIso nro gonornfod.
IInnIIy, fho hnrdwnro socuInfIon schomos rovIdod suorf for roordorIng Ionds
nnd sforos, by chockIng for ofonfInI nddross confIIcfs nf runfImo. To nIIow fho comIIor
fo roordor Ionds nnd sforos whon If susocfs fhoy do nof confIIcf, buf cnnnof bo
nbsoIufoIy corfnIn, n mochnnIsm for chockIng for such confIIcfs cnn bo nddod fo fho
hnrdwnro. ThIs mochnnIsm ormIfs nddIfIonnI oorfunIfIos for momory roforonco
socuInfIon.

CondItIonuI ov PvedIcuted InstvuctIons
Tho concof bohInd condIfIonnI InsfrucfIons Is quIfo sImIo: An InsfrucfIon rofors
fo n condIfIon, whIch Is ovnIunfod ns nrf of fho InsfrucfIon oxocufIon. If fho condIfIon Is
fruo, fho InsfrucfIon Is oxocufod normnIIy; If fho condIfIon Is fnIso, fho oxocufIon
confInuos ns If fho InsfrucfIon wns n no-o.
Computev AvcLItectuve
TLunguveI Muvugun 1?4
Tho mosf common oxnmIo of such nn InsfrucfIon Is condIfIonnI movo, whIch
movos n vnIuo from ono rogIsfor fo nnofhor If fho condIfIon Is fruo. Such nn InsfrucfIon
cnn bo usod fo comIofoIy oIImInnfo n brnnch In sImIo codo soquoncos.
ConsIdor fho foIIowIng codo:
If (A==0)
{
S=T;
}
AssumIng fhnf rogIsfors !l, !2, nnd !3 hoId fho vnIuos of A, S, nnd T, rosocfIvoIy,

Tho sfrnIghfforwnrd codo usIng n brnnch for fhIs sfnfomonf Is
IIZ !l,!
A! !2,!3,!0
!: !sIng n condIfIonnI movo fhnf orforms fho movo onIy If fho fhIrd oornnd Is oqunI fo
zoro, wo cnn ImIomonf fhIs sfnfomonf In ono InsfrucfIon:
CMOVZ !2,!3,!l
Tho condIfIonnI InsfrucfIon nIIows us fo convorf fho confroI doondonco rosonf
In fho brnnch-bnsod codo soquonco fo n dnfn doondonco. Ior n IoIInod rocossor, fhIs
movos fho Inco whoro fho doondonco musf bo rosoIvod from nonr fho fronf of fho
IoIIno, whoro If Is rosoIvod for brnnchos, fo fho ond of fho IoIIno whoro fho rogIsfor
wrIfo occurs.
Ono obvIous uso for condIfIonnI movo Is fo ImIomonf fho nbsoIufo vnIuo
funcfIon: A = nbs (I), whIch Is ImIomonfod ns If (I<0) {A = - I;) oIso {A=I;}. ThIs If
sfnfomonf cnn bo ImIomonfod ns n nIr of condIfIonnI movos, or ns ono uncondIfIonnI
movo (A=I) nnd ono condIfIonnI movo (A= - I).
In fho oxnmIo nbovo or In fho comIInfIon of nbsoIufo vnIuo, condIfIonnI movos
nro usod fo chnngo confroI doondonco Info n dnfn doondonco. ThIs onnbIos us fo
oIImInnfo fho brnnch nnd ossIbIy Imrovo fho IoIIno bohnvIor. CondIfIonnI movos nro
fho sImIosf form of condIfIonnI or rodIcnfod InsfrucfIons, nnd nIfhough usofuI for
shorf soquoncos, hnvo IImIfnfIons.

Computev AvcLItectuve
TLunguveI Muvugun 1?5

In nrfIcuInr, usIng condIfIonnI movo fo oIImInnfo brnnchos fhnf gunrd fho
oxocufIon of Inrgo bIocks of codo cnn bo In offIcIonf, sInco mnny condIfIonnI movos mny
nood fo bo Infroducod.
To romody fho In offIcIoncy of usIng condIfIonnI movos, somo nrchIfocfuros
suorf fuII rodIcnfIon, whoroby fho oxocufIon of nII InsfrucfIons Is confroIIod by n
rodIcnfo. Whon fho rodIcnfo Is fnIso, fho InsfrucfIon bocomos n no-o. IuII rodIcnfIon
nIIows us fo sImIy convorf Inrgo bIocks of codo fhnf nro brnnch doondonf.
Ior oxnmIo, nn If-fhon-oIso sfnfomonf wIfhIn n Ioo cnn bo onfIroIy convorfod fo
rodIcnfod oxocufIon, so fhnf fho codo In fho fhon-cnso oxocufos onIy If fho vnIuo of fho
condIfIon Is fruo, nnd fho codo In fho oIso-cnso oxocufos onIy If fho vnIuo of fho condIfIon
Is fnIso. IrodIcnfIon Is nrfIcuInrIy vnIunbIo wIfh gIobnI codo schoduIIng, sInco If cnn
oIImInnfo nonIoo brnnchos, whIch sIgnIfIcnnfIy comIIcnfo InsfrucfIon schoduIIng.
IrodIcnfod InsfrucfIons cnn nIso bo usod fo socuInfIvoIy movo nn InsfrucfIon
fhnf Is fImo-crIfIcnI, buf mny cnuso nn oxcofIon If movod boforo n gunrdIng brnnch.
AIfhough If Is ossIbIo fo do fhIs wIfh condIfIonnI movo, If Is moro cosfIy.
IrodIcnfod or condIfIonnI InsfrucfIons nro oxfromoIy usofuI for ImIomonfIng
shorf nIfornnfIvo confroI fIows, for oIImInnfIng somo unrodIcfnbIo brnnchos, nnd for
roducIng fho ovorhond of gIobnI codo schoduIIng. onofhoIoss, fho usofuInoss of
condIfIonnI InsfrucfIons Is IImIfod by sovornI fncfors:

IrodIcnfod InsfrucfIons fhnf nro nnnuIIod (I.o., whoso condIfIons nro fnIso) sfIII
fnko somo rocossor rosourcos. An nnnuIIod rodIcnfod InsfrucfIon roquIros fofch
rosourcos nf n mInImum, nnd In mosf rocossors funcfIonnI unIf oxocufIon fImo.
IrodIcnfod InsfrucfIons nro mosf usofuI whon fho rodIcnfo cnn bo ovnIunfod
onrIy. If fho condIfIon ovnIunfIon nnd rodIcnfod InsfrucfIons cnnnof bo
sonrnfod (bocnuso of dnfn doondoncos In doformInIng fho condIfIon), fhon n
condIfIonnI InsfrucfIon mny rosuIf In n sfnII for n dnfn hnznrd. WIfh brnnch
rodIcfIon nnd socuInfIon, such sfnIIs cnn bo nvoIdod, nf Ionsf whon fho
brnnchos nro rodIcfod nccurnfoIy.
Computev AvcLItectuve
TLunguveI Muvugun 1?6
Tho uso of condIfIonnI InsfrucfIons cnn bo IImIfod whon fho confroI fIow InvoIvos
moro fhnn n sImIo nIfornnfIvo soquonco. Ior oxnmIo, movIng nn InsfrucfIon
ncross muIfIIo brnnchos roquIros mnkIng If condIfIonnI on bofh brnnchos, whIch
roquIros fwo condIfIons fo bo socIfIod or roquIros nddIfIonnI InsfrucfIons fo
comufo fho confroIIIng rodIcnfo.
CondIfIonnI InsfrucfIons mny hnvo somo sood onnIfy comnrod wIfh
uncondIfIonnI InsfrucfIons. ThIs mny show u ns n hIghor cycIo counf for such
InsfrucfIons or n sIowor cIock rnfo ovornII. If condIfIonnI InsfrucfIons nro moro
oxonsIvo, fhoy wIII nood fo bo usod judIcIousIy
.
Ior fhoso ronsons, mnny nrchIfocfuros hnvo IncIudod n fow sImIo condIfIonnI
InsfrucfIons (wIfh condIfIonnI movo boIng fho mosf froquonf), buf onIy n fow
nrchIfocfuros IncIudo condIfIonnI vorsIons for fho mnjorIfy of fho InsfrucfIons. Tho
MIIS, AIhn, Iowor-IC, SIA!C nnd InfoI x86 (ns dofInod In fho IonfIum rocossor) nII
suorf condIfIonnI movo. Tho IA-64 nrchIfocfuro suorfs fuII rodIcnfIon for nII
InsfrucfIons.

CompIIev SpecuIutIon wItL Huvdwuve Suppovt
Mnny rogrnms hnvo brnnchos fhnf cnn bo nccurnfoIy rodIcfod nf comIIo fImo
oIfhor from fho rogrnm sfrucfuro or by usIng n rofIIo. In such cnsos, fho comIIor mny
wnnf fo socuInfo oIfhor fo Imrovo fho schoduIIng or fo Incronso fho Issuo rnfo.
IrodIcnfod InsfrucfIons rovIdo ono mofhod fo socuInfo, buf fhoy nro ronIIy moro
usofuI whon confroI doondoncos cnn bo comIofoIy oIImInnfod by If-convorsIon. In
mnny cnsos, wo wouId IIko fo movo socuInfod InsfrucfIons nof onIy boforo brnnch, buf
boforo fho condIfIon ovnIunfIon, nnd rodIcnfIon cnnnof nchIovo fhIs.
As oInfod ouf onrIIor, fo socuInfo nmbIfIousIy roquIros fhroo cnnbIIIfIos:
l. fho nbIIIfy of fho comIIor fo fInd InsfrucfIons fhnf, wIfh fho ossIbIo uso of
rogIsfor ronnmIng, cnn bo socuInfIvoIy movod nnd nof nffocf fho rogrnm dnfn
fIow,
2. fho nbIIIfy fo Ignoro oxcofIons In socuInfod InsfrucfIons, unfII wo know fhnf
such oxcofIons shouId ronIIy occur, nnd
Computev AvcLItectuve
TLunguveI Muvugun 1??
3. Tho nbIIIfy fo socuInfIvoIy Inforchnngo Ionds nnd sforos, or sforos nnd sforos,
whIch mny hnvo nddross confIIcfs.
Tho fIrsf of fhoso Is n comIIor cnnbIIIfy, whIIo fho Insf fwo roquIro hnrdwnro suorf.
Huvdwuve Suppovt Iov PvesevvIng ceptIon BeLuvIov
Thoro nro four mofhods fhnf hnvo boon InvosfIgnfod for suorfIng moro nmbIfIous
socuInfIon wIfhouf InfroducIng orronoous oxcofIon bohnvIor:

l. Tho hnrdwnro nnd oornfIng sysfom cooornfIvoIy Ignoro oxcofIons for
socuInfIvo InsfrucfIons.
2. SocuInfIvo InsfrucfIons fhnf novor rnIso oxcofIons nro usod, nnd chocks nro
Infroducod fo doformIno whon nn oxcofIon shouId occur.
3. A sof of sfnfus bIfs, cnIIod poieon IiIe, nro nffnchod fo fho rosuIf rogIsfors wrIffon
by socuInfod InsfrucfIons whon fho InsfrucfIons cnuso oxcofIons. Tho oIson
bIfs cnuso n fnuIf whon n normnI InsfrucfIon nffomfs fo uso fho rogIsfor.
4. A mochnnIsm Is rovIdod fo IndIcnfo fhnf nn InsfrucfIon Is socuInfIvo nnd fho
hnrdwnro buffors fho InsfrucfIon rosuIf unfII If Is corfnIn fhnf fho InsfrucfIon Is
no Iongor socuInfIvo.

To oxInIn fhoso schomos, wo nood fo dIsfInguIsh bofwoon oxcofIons fhnf
IndIcnfo n rogrnm orror nnd wouId normnIIy cnuso formInnfIon, such ns n momory
rofocfIon vIoInfIon, nnd fhoso fhnf nro hnndIod nnd normnIIy rosumod, such ns n ngo
fnuIf. IxcofIons fhnf cnn bo rosumod cnn bo nccofod nnd rocossod for socuInfIvo
InsfrucfIons jusf ns If fhoy woro normnI InsfrucfIons.
If fho socuInfIvo InsfrucfIon shouId nof hnvo boon oxocufod, hnndIIng fho
unnoodod oxcofIon mny hnvo somo nognfIvo orformnnco offocfs, buf If cnnnof cnuso
Incorrocf oxocufIon. Tho cosf of fhoso oxcofIons mny bo hIgh, howovor, nnd somo
rocossors uso hnrdwnro suorf fo nvoId fnkIng such oxcofIons, jusf ns rocossors
wIfh hnrdwnro socuInfIon mny fnko somo oxcofIons In socuInfIvo modo, whIIo
nvoIdIng ofhors unfII nn InsfrucfIon Is known nof fo bo socuInfIvo.
Computev AvcLItectuve
TLunguveI Muvugun 1?B
IxcofIons fhnf IndIcnfo n rogrnm orror shouId nof occur In corrocf rogrnms,
nnd fho rosuIf of n rogrnm fhnf gofs such nn oxcofIon Is nof woII dofInod, oxcof
orhns whon fho rogrnm Is runnIng In n dobuggIng modo.
If such oxcofIons nrIso In socuInfod InsfrucfIons, wo cnnnof fnko fho oxcofIon
unfII wo know fhnf fho InsfrucfIon Is no Iongor socuInfIvo. In fho sImIosf mofhod for
rosorvIng oxcofIons, fho hnrdwnro nnd fho oornfIng sysfom sImIy hnndIo nII
rosumnbIo oxcofIons whon fho oxcofIon occurs nnd sImIy rofurn nn undofInod vnIuo
for nny oxcofIon fhnf wouId cnuso formInnfIon.
A socond nronch fo rosorvIng oxcofIon bohnvIor whon socuInfIng Infroducos
socuInfIvo vorsIons of InsfrucfIons fhnf do nof gonornfo formInnfIng oxcofIons. A
fhIrd nronch for rosorvIng oxcofIon bohnvIor frncks oxcofIons ns fhoy occur buf
osfonos nny formInnfIng oxcofIon unfII n vnIuo Is ncfunIIy usod, rosorvIng fho
occurronco of fho oxcofIon, nIfhough nof In n comIofoIy rocIso fnshIon.
Tho fourfh nnd fInnI nronch IIsfod nbovo roIIos on n hnrdwnro mochnnIsm fhnf
oornfos IIko n roordor buffor. In such nn nronch, InsfrucfIons nro mnrkod by fho
comIIor ns socuInfIvo nnd IncIudo nn IndIcnfor of how mnny brnnchos fho InsfrucfIon
wns socuInfIvoIy movod ncross nnd whnf brnnch ncfIon (fnkon/nof fnkon) fho comIIor
nssumod.
AII InsfrucfIons nro Incod In n roordor buffor whon Issuod nnd nro forcod fo
commIf In ordor, ns In n hnrdwnro socuInfIon nronch. Tho roordor buffor frncks
whon InsfrucfIons nro rondy fo commIf nnd doInys fho wrIfo bnck orfIon of nny
socuInfIvo InsfrucfIon. SocuInfIvo InsfrucfIons nro nof nIIowod fo commIf unfII fho
brnnchos fhoy hnvo boon socuInfIvoIy movod ovor nro nIso rondy fo commIf, or,
nIfornnfIvoIy, unfII fho corrosondIng sonfInoI Is ronchod.

Huvdwuve Suppovt Iov Memovy ReIevence SpecuIutIon
MovIng Ionds ncross sforos Is usunIIy dono whon fho comIIor Is corfnIn fho
nddrossos do nof confIIcf. To nIIow fho comIIor fo undorfnko such codo mofIon, whon If
cnnnof bo nbsoIufoIy corfnIn fhnf such n movomonf Is corrocf, n socInI InsfrucfIon fo
chock for nddross confIIcfs cnn bo IncIudod In fho nrchIfocfuro.
Computev AvcLItectuve
TLunguveI Muvugun 1?9
Tho socInI InsfrucfIon Is Ioff nf fho orIgInnI IocnfIon of fho Iond InsfrucfIon (nnd
ncfs IIko n gunrdInn) nnd fho Iond Is movod u ncross ono or moro sforos. Whon n
socuInfod Iond Is oxocufod, fho hnrdwnro snvos fho nddross of fho nccossod momory
IocnfIon. If n subsoquonf sforo chnngos fho IocnfIon boforo fho chock InsfrucfIon, fhon
fho socuInfIon hns fnIIod. If fho IocnfIon hns nof boon fouchod fhon fho socuInfIon Is
succossfuI.
SocuInfIon fnIIuro cnn bo hnndIod In fwo wnys. If onIy fho Iond InsfrucfIon wns
socuInfod, fhon If suffIcos fo rodo fho Iond nf fho oInf of fho chock InsfrucfIon If
nddIfIonnI InsfrucfIons fhnf doondod on fho Iond woro nIso socuInfod, fhon n fIx-u
soquonco fhnf ro-oxocufos nII fho socuInfod InsfrucfIons sfnrfIng wIfh fho Iond Is
noodod.

3.6 CROSSCUTTING ISSUS
HARWAR VRSUS SOITWAR SPCUIATION MCHANISMS

Computev AvcLItectuve
TLunguveI Muvugun 1B0


3.? TH INTI IA-64 ARCHITCTUR AN ITANIUM PROCSSOR

TLe InteI IA-64 InstvuctIon Set AvcLItectuve
Tho IA-64 Is n !ISC-sfyIo, rogIsfor-rogIsfor InsfrucfIon sof. Our focus horo Is on fho
unIquo nsocfs of fho IA-64 ISA.

TLe IA-64 RegIstev ModeI
Tho comononfs of fho IA-64 rogIsfor sfnfo nro:
l28 64-bIf gonornI-uroso rogIsfors, whIch ns wo wIII soo shorfIy nro ncfunIIy
65 bIfs wIdo;
l28 82-bIf fIonfIng oInf rogIsfors, whIch rovIdos fwo oxfrn oxononf bIfs ovor
fho sfnndnrd 80-bIf IIII formnf,
64 l-bIf rodIcnfo rogIsfors,
8 64-bIf brnnch rogIsfors, whIch nro usod for IndIrocf brnnchos, nnd
n vnrIofy of rogIsfors usod for sysfom confroI, momory mnIng, orformnnco
counfors, nnd communIcnfIon wIfh fho OS.

!ogIsfors 0-3l nro nIwnys nccossIbIo nnd nro nddrossod ns 0-3l. !ogIsfors 32-l28
nro usod ns n rogIsfor sfnck nnd onch rocoduro Is nIIocnfod n sof of rogIsfors (from 0 fo
96) for Ifs uso.Tho now rogIsfor sfnck frnmo Is cronfod for n cnIIod rocoduro by
ronnmIng fho rogIsfors In hnrdwnro; n socInI rogIsfor cnIIod fho curronf frnmo oInfor
(CIM) oInfs fo fho sof of rogIsfors fo bo usod by n gIvon rocoduro.

Computev AvcLItectuve
TLunguveI Muvugun 1B1
Tho frnmo consIsfs of fwo nrfs: fho IocnI nron nnd fho oufuf nron. Tho IocnI
nron Is usod for IocnI sforngo, whIIo fho oufuf nron Is usod fo nss vnIuos fo nny cnIIod
rocoduro. Tho nIIoc InsfrucfIon socIfIos fho sIzo of fhoso nrons. OnIy fho Infogor
rogIsfors hnvo rogIsfor sfnck suorf.
On n rocoduro cnII, fho CIM oInfor Is udnfod so fhnf !32 of fho cnIIod
rocoduro oInfs fo fho fIrsf rogIsfor of fho oufuf nron of fho cnIIod rocoduro. ThIs
udnfo onnbIos fho nrnmofors of fho cnIIor fo bo nssod Info fho nddrossnbIo rogIsfors
of fho cnIIoo.
Tho cnIIoo oxocufos nn nIIoc InsfrucfIon fo nIIocnfo bofh fho numbor of roquIrod
IocnI rogIsfors, whIch IncIudo fho oufuf rogIsfors of fho cnIIor, nnd fho numbor of
oufuf rogIsfors noodod for nrnmofor nssIng fo n cnIIod rocoduro. SocInI Iond nnd
sforo InsfrucfIons nro nvnIInbIo for snvIng nnd rosforIng fho rogIsfor sfnck, nnd socInI
hnrdwnro (cnIIod fho regieIer eIocl engine) hnndIos ovorfIow of fho rogIsfor sfnck.
In nddIfIon fo fho Infogor rogIsfors, fhoro nro fhroo ofhor sofs of rogIsfors: fho
fIonfIng oInf rogIsfors, fho rodIcnfo rogIsfors, nnd fho brnnch rogIsfors. Tho fIonfIng
oInf rogIsfors nro usod for fIonfIng oInf dnfn, nnd fho brnnch rogIsfors nro usod fo
hoId brnnch dosfInnfIon nddrossos for IndIrocf brnnchos.
Tho rodIcnfIon rogIsfors hoId rodIcnfos, whIch confroI fho oxocufIon of
rodIcnfod InsfrucfIons; wo doscrIbo fho rodIcnfIon mochnnIsm Infor In fhIs socfIon.
Iofh fho Infogor nnd fIonfIng oInf rogIsfors suorf rogIsfor rofnfIon for rogIsfors 32-
l28. !ogIsfor rofnfIon Is dosIgnod fo onso fho fnsk of nIIocnfIng of rogIsfors In soffwnro
IoIInod Ioos

InstvuctIon Iovmut und Suppovt Iov pIIcIt PuvuIIeIIsm
Tho IA-64 nrchIfocfuro Is dosIgnod fo nchIovo fho mnjor bonofIfs of n V!IW-
nronch ImIIcIf nrnIIoIIsm nmong oornfIons In nn InsfrucfIon nnd fIxod formnffIng
of fho oornfIon fIoIdswhIIo mnInfnInIng gronfor fIoxIbIIIfy fhnn n V!IW normnIIy
nIIows.
Tho IA-64 nrchIfocfuro usos fwo dIfforonf concofs fo nchIovo fho bonofIfs of
ImIIcIf nrnIIoIIsm nnd onso of InsfrucfIon docodo. ImIIcIf nrnIIoIIsm Is nchIovod by
IncIng InsfrucfIons Info ineIrucIion groupe, whIIo fho fIxod formnffIng of muIfIIo
Computev AvcLItectuve
TLunguveI Muvugun 1B2
InsfrucfIons Is nchIovod fhrough fho InfroducfIon of n concof cnIIod n IunJle, whIch
confnIns fhroo InsfrucfIons.
An ineIrucIion group Is n soquonco of consocufIvo InsfrucfIons wIfh no rogIsfor
dnfn doondoncos nmong fhom (fhoro nro n fow mInor oxcofIons). AII fho InsfrucfIons
In n grou couId bo oxocufod In nrnIIoI, If suffIcIonf hnrdwnro rosourcos oxIsfod nnd If
nny doondonco fhrough momory woro rosorvod.
An InsfrucfIon grou cnn bo nrbIfrnrIIy Iong, buf fho comIIor musf expliciIl,
IndIcnfo fho boundnry bofwoon ono InsfrucfIon grou nnd nnofhor. ThIs boundnry Is
IndIcnfod by IncIng n eIop bofwoon fwo InsfrucfIons fhnf boIong fo dIfforonf grous.
IA-64 InsfrucfIons nro oncodod In IunJlee, whIch nro l28 bIfs wIdo. Inch bundIo
consIsfs of n fIvo-bIf fomInfo fIoId nnd fhroo InsfrucfIons, onch 4l bIfs In Iongfh. To
sImIy fho docodIng nnd InsfrucfIon Issuo rocoss, fho fomInfo fIoId of n bundIo
socIfIos whnf fyos of oxocufIon unIf onch InsfrucfIon In fho bundIo roquIros.
Tho fIvo-bIf fomInfo fIoId wIfhIn onch bundIo doscrIbos IoII fho rosonco of nny
sfos nssocInfod wIfh fho bundIo nnd fho oxocufIon unIf fyo roquIrod by onch
InsfrucfIon wIfhIn fho bundIo.

TLe IIve eecutIon unIt sIots In tLe IA-64 uvcLItectuve und wLut
InstvuctIons types

InstvuctIon Set BusIcs
Inch IA-64 InsfrucfIon Is 4l bIfs In Iongfh. Tho hIgh-ordor four bIfs, fogofhor
wIfh fho bundIo bIfs fhnf socIfy fho oxocufIon unIf sIof, nro usod ns fho mnjor ocodo.
Tho Iow ordor sIx-bIf of ovory InsfrucfIon nro usod for socIfyIng fho rodIcnfo rogIsfor
fhnf gunrds fho InsfrucfIon.
Computev AvcLItectuve
TLunguveI Muvugun 1B3

PvedIcutIon und SpecuIutIon Suppovt
Tho IA-64 nrchIfocfuro rovIdos comrohonsIvo suorf for rodIcnfIon: nonrIy
ovory InsfrucfIon In fho IA-64 nrchIfocfuro cnn bo rodIcnfod. An InsfrucfIon Is
rodIcnfod by n socIfyIng n rodIcnfo rogIsfor, whoso IdonfIfy Is Incod In fho Iowor sIx
bIfs of onch InsfrucfIon fIoId. Iocnuso nonrIy nII InsfrucfIons cnn bo rodIcnfod, bofh If-
convorsIon nnd codo mofIon hnvo Iowor ovorhond fhnn fhoy wouId wIfh onIy IImIfod
suorf for condIfIonnI InsfrucfIons.
IrodIcnfo rogIsfors nro sof usIng comnro or fosf InsfrucfIons. A comnro
InsfrucfIon socIfIos ono of fon dIfforonf comnrIson fosfs nnd fwo rodIcnfo rogIsfors ns
dosfInnfIons. Tho fwo rodIcnfo rogIsfors nro wrIffon oIfhor wIfh fho rosuIf of fho
comnrIson (0 or l) nnd fho comIomonf, or wIfh somo IogIcnI funcfIon fhnf combInos
fho fwo fosfs (such ns nnd) nnd fho comIomonf. ThIs cnnbIIIfy nIIows muIfIIo
comnrIsons fo bo dono In ono InsfrucfIon.
SocuInfIon suorf In fho IA-64 nrchIfocfuro consIsfs of sonrnfo suorf for
confroI socuInfIon, whIch donIs wIfh doforrIng oxcofIon for socuInfod InsfrucfIons,
nnd momory roforonco socuInfIon, whIch suorfs socuInfIon of Iond InsfrucfIons.
oforrod oxcofIon hnndIIng for socuInfIvo InsfrucfIons Is suorfod by
rovIdIng fho oquIvnIonf of oIson bIfs. Ior fho CI!s, fhoso bIfs nro cnIIod nTs for of
n ThIng, nnd fhIs oxfrn bIf mnkos fho CI!s offocfIvoIy 65 bIfs wIdo. Ior fho II
rogIsfors fhIs cnnbIIIfy Is obfnInod usIng n socInI vnIuo, nTVnI, for of A ThIng
VnIuo; fhIs vnIuo Is oncodod usIng n sIgnIfIcnnd of 0 nnd nn oxononf oufsIdo of fho
IIII rnngo.
A doforrod oxcofIon cnn bo rosoIvod In fwo dIfforonf wnys. IIrsf, If n
nonsocuInfIvo InsfrucfIon, such ns n sforo, rocoIvos n nT or nTVnI ns n sourco
oornnd, If gonornfos nn ImmodInfo nnd unrocovornbIo oxcofIon. AIfornnfIvoIy, n chk.s
InsfrucfIon cnn bo usod fo dofocf fho rosonco of nT or nfVnI nnd brnnch fo n roufIno
dosIgnod by fho comIIor fo rocovor from fho socuInfIvo oornfIon. Such n rocovory
nronch mnkos moro sonso for momory roforonco socuInfIon.

Computev AvcLItectuve
TLunguveI Muvugun 1B4
Tho InnbIIIfy fo sforo fho confonfs of InsfrucfIons wIfh nT or nfVnI sof wouId
mnko If ImossIbIo for fho OS fo snvo fho sfnfo of fho rocossor. Thus, IA- 64 IncIudos
socInI InsfrucfIons fo snvo nnd rosforo rogIsfors fhnf do nof cnuso nn oxcofIon for n
nT or nTVnI nnd nIso snvo nnd rosforo fho nT bIfs.
Momory roforonco suorf In fho IA-64 usos n concof cnIIod ndvnncod Ionds. An
oJtonceJ looJ Is n Iond fhnf hns boon socuInfIvoIy movod nbovo sforo InsfrucfIons on
whIch If Is ofonfInIIy doondonf. To socuInfIvoIy orform n Iond, fho Id.n (for
ndvnncod Iond) InsfrucfIon Is usod.

TLe ItunIum Pvocessov
Tho IfnnIum rocossor Is fho fIrsf ImIomonfnfIon of fho IA-64 nrchIfocfuro. If
bocnmo nvnIInbIo In fho mIddIo of 200l wIfh nn 800 MHz cIock. Tho rocossor coro Is
cnnbIo of u fo sIx Issuos or cIock, wIfh u fo fhroo brnnchos nnd fwo momory
roforoncos. Tho momory hIornrchy consIsfs of n fhroo-IovoI cncho. Tho fIrsf IovoI usos
sIIf InsfrucfIon nnd dnfn cnchos; fIonfIng oInf dnfn Is nof Incod In fho fIrsf IovoI
cncho. Tho socond nnd fhIrd IovoIs nro unIfIod cnchos, wIfh fho fhIrd IovoI boIng nn off-
chI 4MI cncho Incod In fho snmo confnInor ns fho IfnnIum dIo.

IunctIonuI UnIts und InstvuctIon Issue
Thoro nro nIno funcfIonnI unIfs In fho IfnnIum rocossor: 2 I-unIfs, 2 M-unIfs, 3
I-unIfs, nnd 2 I-unIfs. AII fho funcfIonnI unIfs nro IoIInod. IIguro gIvos fho IoIIno
InfoncIos for somo fyIcnI InsfrucfIons. In nddIfIon, whon n rosuIf Is bynssod from ono
unIf fo nnofhor, fhoro Is usunIIy nf Ionsf ono nddIfIonnI cycIo of doIny.

TLe Iutency oI some typIcuI InstvuctIons on ItunIum.
Computev AvcLItectuve
TLunguveI Muvugun 1B5
Tho IfnnIum rocossor usos n l0-sfngo IoIIno dIvIdod Info four mnjor nrfs:
l. Ironf-ond (sfngos IIC, Iofch, nnd !ofnfo): rofofchos u fo 32 byfos or cIock (2
bundIos) Info n rofofch buffor, whIch cnn hoId u fo oIghf bundIos (24
InsfrucfIons). Irnnch rodIcfIon Is dono usIng n muIfIIovoI ndnfIvo rodIcfor
IIko fhnf In fho I6 mIcronrchIfocfuro.
2. InsfrucfIon doIIvory (sfngos IXI nnd !I): dIsfrIbufos u fo sIx InsfrucfIons fo
fho nIno funcfIonnI unIfs. ImIomonfs rogIsfors ronnmIng for bofh rofnfIon nnd
rogIsfor sfnckIng.
3. Oornnd doIIvory (W! nnd !IC): nccossos fho rogIsfor fIIo, orforms rogIsfor
bynssIng, nccossos nnd udnfos n rogIsfor scorobonrd, nnd chocks rodIcnfo
doondoncos. Tho scorobonrd Is usod fo dofocf whon IndIvIdunI InsfrucfIons cnn
rocood, so fhnf n sfnII of ono InsfrucfIon In n bundIo nood nof cnuso fho onfIro
bundIo fo sfnII
4. IxocufIon (IXI, IT, nnd W!I): oxocufos InsfrucfIons fhrough A!!s nnd
Iond/sforo unIfs, dofocfs oxcofIons nnd osfs nTs, rofIros InsfrucfIons nnd
orforms wrIfo-bnck.

ItunIum PevIovmunce
IIguro shows fho orformnnco of nn 800 MHz IfnnIum vorsus n l CHz AIhn
2l264 nnd n 2 CHz IonfIum 4 for SIICInf. Tho IfnnIum Is onIy nbouf 60 of fho
orformnnco of fho IonfIum 4 nnd 68 of fho orformnnco of fho AIhn 2l264.
OvornII, fho IfnnIum rocossor Is l.08 fImos fnsfor fhnn fho IonfIum 4 nnd nbouf
l.20 fImos fnsfor fhnn fho AIhn 2l264, nf n cIock rnfo fhnf Is onIy 40 fo 80 ns hIgh.
Ior fIonfIng oInf nIIcnfIons, fho IfnnIum Iooks IIko n vory comofIfIvo rocossor.
Thoro nro fwo unusunI nsocfs of fho SIICf orformnnco monsuromonfs. IIrsf,
fho IfnnIum gnIns Ifs orformnnco ndvnnfngo ovor fho IonfIum 4 rImnrIIy on fho
sfrongfh of Ifs orformnnco on ono bonchmnrk: nrf, whoro If Is ovor four fImos fnsfor
fhnn fho IonfIum 4. If fho bonchmnrk nrf wns oxcIudod, fho IonfIum 4 wouId
ouforform fho IfnnIum for SIICf. Tho ofhor unusunI nsocf of fhIs orformnnco dnfn
Is fhnf fho AIhn rocossor shows n Inrgo gn of nImosf 30 bofwoon funod nnd bnso
orformnnco for SIICf.
Computev AvcLItectuve
TLunguveI Muvugun 1B6

TLe SPCInt bencLmuvk set sLows tLut tLe ItunIum Is consIdevubIy sIowev
tLun eItLev tLe AIp-Lu 21264 ov tLe PentIum 4.

ThIs comnros fo n gn bofwoon bnso nnd onk for fho IfnnIum sysfom of 0 nnd
for fho IonfIum 4 sysfom of 3. !ookIng nf fho bonchmnrk socIfIc fIngs for fho AIhn
sysfom, whIch rImnrIIy doscrIbo Ioo unroIIIng ofImIznfIons, If nonrs fhnf fhIs
dIfforonco Is duo fo comIIor ImmnfurIfy for fho AIhn sysfom. If fho bnso orformnnco
couId bo broughf fo 95 of fho onk orformnnco, fho AIhn sysfom wouId hnvo fho
hIghosf SIICf rnfIng nmong fhoso fhroo rocossors.

****N***




Computev AvcLItectuve
TLunguveI Muvugun 1B?
UNIT IV
MMORY-HIRARCHY SIGN

4.1 INTROUCTION
Irogrnmmors nood unIImIfod nmounfs of fnsf momory. An oconomIcnI soIufIon fo
fhnf dosIro Is n memory hierurchy, whIch fnkos ndvnnfngo of IocnIIfy nnd
cosf/orformnnco of momory fochnoIogIos. Tho principle of loculity, mosf rogrnms do
nof nccoss nII codo or dnfn unIformIy.
SInco fnsf momory Is oxonsIvo, n momory hIornrchy Is orgnnIzod Info sovornI
IovoIsonch smnIIor, fnsfor, nnd moro oxonsIvo or byfo fhnn fho noxf Iowor IovoI.
Tho gouI Is fo rovIdo n momory sysfom wIfh cosf nImosf ns Iow ns fho chonosf
IovoI of momory nnd sood nImosf ns fnsf ns fho fnsfosf IovoI. Tho IovoIs of fho hIornrchy
usunIIy subsof ono nnofhor. AII dnfn In ono IovoI Is nIso found In fho IovoI boIow nnd nII
dnfn In fhnf Iowor IovoI Is found In fho ono boIow If, nnd so on unfII wo ronch fho boffom
of fho hIornrchy.
Inch IovoI mns nddrossos from n sIowor, Inrgor momory fo n smnIIor buf fnsfor
momory hIghor In fho hIornrchy. As nrf of nddross mnIng, fho momory hIornrchy Is
gIvon fho rosonsIbIIIfy of nddross chockIng. Tho Imorfnnco of fho momory hIornrchy
hns Incronsod wIfh ndvnncos In orformnnco of rocossors.



TLe IeveIs In u typIcuI memovy LIevuvcLy In embedded, desktop, und sevvev
computevs.

Computev AvcLItectuve
TLunguveI Muvugun 1BB

esktop und mbedded Computevs:
oskfo comufors nro rImnrIIy runnIng ono nIIcnfIon nf n fImo on fo of nn
oornfIng sysfom for n sIngIo usor, whorons sorvor comufors mny fyIcnIIy hnvo
hundrods of usors ofonfInIIy runnIng ofonfInIIy dozons of nIIcnfIons
sImuIfnnoousIy.
oskfo comufors nro concornod moro wIfh nvorngo Infoncy from fho momory
hIornrchy whorons sorvor comufors nro nIso concornod nbouf momory bnndwIdfh. Tho
momory hIornrchy of fho omboddod comufors Is offon quIfo dIfforonf from fhnf of fho
doskfo nnd sorvor.
l. Imboddod comufors nro offon usod In ronI-fImo nIIcnfIons, nnd honco
rogrnmmors musf worry nbouf worsf cnso orformnnco.
2. Imboddod nIIcnfIons nro offon concornod nbouf owor nnd bnffory IIfo.
Tho bosf wny fo snvo owor Is fo hnvo Ioss hnrdwnro.
3. Imboddod nIIcnfIons nro fyIcnIIy onIy runnIng ono nIIcnfIon nnd uso
n vory sImIo oornfIng sysfom, If fhoy ono nf nII.
Honco, fho rofocfIon roIo of fho momory hIornrchy Is offon dImInIshod. IInnIIy, fho
mnIn momory IfsoIf mny bo quIfo smnIIIoss fhnn ono mognbyfonnd fhoro Is offon no
dIsk sforngo.

CucLe:
Cuche Is fho nnmo gIvon fo fho fIrsf IovoI of fho momory hIornrchy oncounforod
onco fho nddross Ionvos fho CI!. SInco fho rIncIIo of IocnIIfy nIIos nf mnny IovoIs,
nnd fnkIng ndvnnfngo of IocnIIfy fo Imrovo orformnnco Is ouInr, fho form cocIe Is
now nIIod whonovor bufforIng Is omIoyod fo rouso commonIy occurrIng Ifoms.
IxnmIos IncIudo file cocIee, none cocIee, nnd so on.
Whon fho CI! fInds n roquosfod dnfn Ifom In fho cncho, If Is cnIIod n cuche hit.
Whon fho CI! doos nof fInd n dnfn Ifom If noods In fho cncho, n cuche mioo occurs. A
fIxod-sIzo coIIocfIon of dnfn confnInIng fho roquosfod word, cnIIod n block, Is rofrIovod
from fho mnIn momory nnd Incod Info fho cncho.

Computev AvcLItectuve
TLunguveI Muvugun 1B9
Temporul loculity foIIs us fhnf wo nro IIkoIy fo nood fhIs word ngnIn In fho
nonr fufuro, so If Is usofuI fo Inco If In fho cncho whoro If cnn bo nccossod quIckIy.
Iocnuso of oputiul loculity, fhoro Is hIgh robnbIIIfy fhnf fho ofhor dnfn In fho bIock
wIII bo noodod soon.
Tho fImo roquIrod for fho cncho mIss doonds on bofh fho Infoncy nnd bnndwIdfh
of fho momory. !nfoncy doformInos fho fImo fo rofrIovo fho fIrsf word of fho bIock, nnd
bnndwIdfh doformInos fho fImo fo rofrIovo fho rosf of fhIs bIock.
A cncho mIss Is hnndIod by hnrdwnro nnd cnusos rocossors foIIowIng In-ordor
oxocufIon fo nuso, or sfnII, unfII fho dnfn nro nvnIInbIo. If fho comufor hns tirtuul
memory, fhon somo objocfs mny rosIdo on dIsk. Tho nddross snco Is usunIIy brokon
Info fIxod-sIzo bIocks, cnIIod pugeo. Af nny fImo, onch ngo rosIdos oIfhor In mnIn
momory or on dIsk.
Whon fho CI! roforoncos nn Ifom wIfhIn n ngo fhnf Is nof rosonf In fho cncho
or mnIn momory, n puge fuult occurs, nnd fho onfIro ngo Is movod from fho dIsk fo
mnIn momory. SInco ngo fnuIfs fnko so Iong, fhoy nro hnndIod In soffwnro nnd fho
CI! Is nof sfnIIod. Tho CI! usunIIy swIfchos fo somo ofhor fnsk whIIo fho dIsk nccoss
occurs. Tho cncho nnd mnIn momory hnvo fho snmo roInfIonshI ns fho mnIn momory
nnd dIsk.

4.2 CACH PRIORMANC RVIW
Iocnuso of IocnIIfy nnd fho hIghor sood of smnIIor momorIos, n momory
hIornrchy cnn subsfnnfInIIy Imrovo orformnnco. Ono mofhod fo ovnIunfo cncho
orformnnco Is fo oxnnd our CI! oxocufIon fImo oqunfIon.
Tho numbor of cycIos durIng whIch fho CI! Is sfnIIod wnIfIng for n momory
nccoss, whIch wo cnII fho memory otull cycleo. Tho orformnnco Is fhon fho roducf of
fho cIock cycIo fImo nnd fho sum of fho CI! cycIos nnd fho momory sfnII cycIos:

CI! oxocufIon fImo = (CI! cIock cycIos + Momory sfnII cycIos) CIock cycIo fImo

Tho numbor of momory sfnII cycIos doonds on bofh fho numbor of mIssos nnd
fho cosf or mIss, whIch Is cnIIod fho mioo penulty:
Computev AvcLItectuve
TLunguveI Muvugun 190

Tho comononf mioo rute Is sImIy fho frncfIon of cncho nccossos fhnf rosuIf In n
mIss (I.o., numbor of nccossos fhnf mIss dIvIdod by numbor of nccossos).
MIss rnfos cnn bo monsurod wIfh cncho sImuInfors fhnf fnko nn uJJreoo truce
of fho InsfrucfIon nnd dnfn roforoncos, sImuInfo fho cncho bohnvIor fo doformIno whIch
roforoncos hIf nnd whIch mIss, nnd fhon roorf fho hIf nnd mIss fofnIs.
Momory sfnII cIock cycIos couId fhon bo dofInod In forms of fho numbor of
momory nccossos or InsfrucfIon, mIss onnIfy (In cIock cycIos) for ronds nnd wrIfos,
nnd mIss rnfo for ronds nnd wrIfos:



Tho comIofo formuIn by combInIng fho ronds nnd wrIfos nnd fIndIng fho
nvorngo mIss rnfos nnd mIss onnIfy for ronds onJ wrIfos:



MonsurIng mIss rnfo ns miooeo per inotruction rnfhor fhnn mIssos or momory
roforonco. Thoso fwo nro roInfod:


Tho ndvnnfngo of mIssos or InsfrucfIon Is fhnf If Is Indoondonf of fho hnrdwnro
ImIomonfnfIon. Tho drnwbnck Is fhnf mIssos or InsfrucfIon Is nrchIfocfuro doondonf.

Computev AvcLItectuve
TLunguveI Muvugun 191
Iouv Memovy HIevuvcLy QuestIons

Ql: Whoro cnn n bIock bo Incod In fho uor IovoI` (Blocl plocenenI)
Q2: How Is n bIock found If If Is In fho uor IovoI` (Blocl iJenIificoIion)
Q3: WhIch bIock shouId bo roIncod on n mIss` (Blocl replocenenI)
Q4: Whnf hnons on n wrIfo` (WriIe eIroIeg,)

Q1: WLeve cun u bIock be pIuced In u cucLe?

A bIock Is Incod cronfo fhroo cnfogorIos of cncho orgnnIznfIon:
If onch bIock hns onIy ono Inco If cnn nonr In fho cncho, fho cncho Is snId fo bo
Jirect muppeJ. Tho mnIng Is usunIIy
(Blocl oJJreee) MO (AunIer of Ilocle in cocIe)

If n bIock cnn bo Incod nnywhoro In fho cncho, fho cncho Is snId fo be fully
uooociutite.

If n bIock cnn bo Incod In n rosfrIcfod sof of Incos In fho cncho, fho cncho Is oet
uooociutite. A eeI Is n grou of bIocks In fho cncho. A bIock Is fIrsf mnod onfo
n sof, nnd fhon fho bIock cnn bo Incod nnywhoro wIfhIn fhnf sof. Tho sof Is
usunIIy choson by IiI eelecIion; fhnf Is,

(Block uJJreoo) MO (umber of oeto in cuche)

If fhoro nro n bIocks In n sof, fho cncho Incomonf Is cnIIod n-uo, eeI oeeocioIite.

Irocf mnod Is sImIy ono-wny sof nssocInfIvo nnd n fuIIy nssocInfIvo cncho
wIfh n bIocks couId bo cnIIod n-wny sof nssocInfIvo. IquIvnIonfIy, dIrocf mnod cnn bo
fhoughf of ns hnvIng n sofs nnd fuIIy nssocInfIvo ns hnvIng ono sof.

Computev AvcLItectuve
TLunguveI Muvugun 192

TLIs eumpIe cucLe Lus eIgLt bIock Ivumes und memovy Lus 32 bIocks.

Q2: How Is u bIock Iound II It Is In tLe cucLe?
Cnchos hnvo nn nddross fng on onch bIock frnmo fhnf gIvos fho bIock nddross.
Tho fng of ovory cncho bIock fhnf mIghf confnIn fho dosIrod InformnfIon Is chockod fo
soo If If mnfchos fho bIock nddross from fho CI!.
Tho mosf common rocoduro Is fo ndd n toliJ IiI fo fho fng fo sny whofhor or nof
fhIs onfry confnIns n vnIId nddross. If fho bIf Is nof sof, fhoro cnnnof bo n mnfch on fhIs
nddross.
Tho fIrsf dIvIsIon Is bofwoon fho block uJJreoo und tLe block offoet. Tho bIock
frnmo nddross cnn bo furfhor dIvIdod Info fho Iog fIoId nnd fho inJex fIoId. Tho bIock-
offsof fIoId soIocfs fho dosIrod dnfn from fho bIock, fho Indox fIoId soIocfs fho sof, nnd
fho fng fIoId Is comnrod ngnInsf If for n hIf.
AIfhough fho comnrIson couId bo mndo on moro of fho nddross fhnn fho fng,
fhoro Is no nood bocnuso of fho foIIowIng:
Computev AvcLItectuve
TLunguveI Muvugun 193
Tho offsof shouId nof bo usod In fho comnrIson, sInco fho onfIro bIock Is rosonf
or nof, nnd honco nII bIock offsofs rosuIf In n mnfch by dofInIfIon.
ChockIng fho Indox Is rodundnnf, sInco If wns usod fo soIocf fho sof fo bo
chockod. An nddross sforod In sof 0, for oxnmIo, musf hnvo 0 In fho Indox fIoId
or If couIdn`f bo sforod In sof 0; sof l musf hnvo nn Indox vnIuo of l; nnd so on.
ThIs ofImIznfIon snvos hnrdwnro nnd owor by roducIng fho wIdfh of momory
sIzo for fho cncho fng.
If fho fofnI cncho sIzo Is kof fho snmo, IncronsIng nssocInfIvIfy Incronsos fho
numbor of bIocks or sof, fhoroby docronsIng fho sIzo of fho Indox nnd IncronsIng fho
sIzo of fho fng.

TLe tLvee povtIons oI un uddvess In u set-ussocIutIve ov dIvect-mupped cucLe.

Q3: WLIcL bIock sLouId be vepIuced on u cucLe mIss?
Whon n mIss occurs, fho cncho confroIIor musf soIocf n bIock fo bo roIncod wIfh
fho dosIrod dnfn. A bonofIf of dIrocf-mnod Incomonf Is fhnf hnrdwnro docIsIons nro
sImIIfIodIn fncf, so sImIo fhnf fhoro Is no choIco: OnIy ono bIock frnmo Is chockod
for n hIf, nnd onIy fhnf bIock cnn bo roIncod. WIfh fuIIy nssocInfIvo or sof-nssocInfIvo
Incomonf, fhoro nro mnny bIocks fo chooso from on n mIss. Thoro nro fhroo rImnry
sfrnfogIos omIoyod for soIocfIng whIch bIock fo roInco:
RunJomTo srond nIIocnfIon unIformIy, cnndIdnfo bIocks nro rnndomIy
soIocfod.
Leuot-recently uoeJ (IRU)To roduco fho chnnco of fhrowIng ouf InformnfIon
fhnf wIII bo noodod soon, nccossos fo bIocks nro rocordod. !!! roIIos on n
coroIInry of IocnIIfy: If roconfIy usod bIocks nro IIkoIy fo bo usod ngnIn, fhon n
good cnndIdnfo for dIsosnI Is fho Ionsf-roconfIy usod bIock.
Computev AvcLItectuve
TLunguveI Muvugun 194
Firot 1n Firot Out (IIIO)Iocnuso !!! cnn bo comIIcnfod fo cnIcuInfo, fhIs
nroxImnfos !!! by doformInIng fho olJeeI bIock rnfhor fhnn fho !!!.

Q4: WLut Luppens on u wvIte?
!onds domInnfo rocossor cncho nccossos. AII InsfrucfIon nccossos nro ronds, nnd
mosf InsfrucfIons don`f wrIfo fo momory.
Tho bIock cnn bo rond from cncho nf fho snmo fImo fhnf fho fng Is rond nnd
comnrod, so fho bIock rond bogIns ns soon ns fho bIock nddross Is nvnIInbIo. If fho rond
Is n hIf, fho roquosfod nrf of fho bIock Is nssod on fo fho CI! ImmodInfoIy. If If Is n
mIss, fhoro Is no bonofIfbuf nIso no hnrm In doskfo nnd sorvor comufors; jusf
Ignoro fho vnIuo rond.
Tho wrIfo oIIcIos offon dIsfInguIsh cncho dosIgns. Thoro nro fwo bnsIc ofIons
whon wrIfIng fo fho cncho:
Write through Tho InformnfIon Is wrIffon fo bofh fho bIock In fho cncho onJ
fo fho bIock In fho Iowor-IovoI momory.
Write buck Tho InformnfIon Is wrIffon onIy fo fho bIock In fho cncho. Tho
modIfIod cncho bIock Is wrIffon fo mnIn momory onIy whon If Is roIncod.

To roduco fho froquoncy of wrIfIng bnck bIocks on roIncomonf, n fonfuro cnIIod
fho Jirty bit Is commonIy usod. ThIs sfnfus bIf IndIcnfos whofhor fho bIock Is Jirty
(modIfIod whIIo In fho cncho) or cleun (nof modIfIod). If If Is cIonn, fho bIock Is nof
wrIffon bnck on n mIss, sInco IdonfIcnI InformnfIon fo fho cncho Is found In Iowor IovoIs.
Iofh wrIfo bnck nnd wrIfo fhrough hnvo fhoIr ndvnnfngos. WIfh wrIfo bnck, wrIfos
occur nf fho sood of fho cncho momory, nnd muIfIIo wrIfos wIfhIn n bIock roquIro onIy
ono wrIfo fo fho Iowor-IovoI momory.
WrIfo fhrough Is onsIor fo ImIomonf fhnn wrIfo bnck. Tho cncho Is nIwnys cIonn,
so unIIko wrIfo bnck rond mIssos novor rosuIf In wrIfos fo fho Iowor IovoI. WrIfo fhrough
nIso hns fho ndvnnfngo fhnf fho noxf Iowor IovoI hns fho mosf curronf coy of fho dnfn,
whIch sImIIfIos dnfn cohoroncy.Whon fho CI! musf wnIf for wrIfos fo comIofo durIng
wrIfo fhrough, fho CI! Is snId fo urite otull.

Computev AvcLItectuve
TLunguveI Muvugun 195

A common ofImIznfIon fo roduco wrIfo sfnIIs Is n urite buffer, whIch nIIows fho
rocossor fo confInuo ns soon ns fho dnfn Is wrIffon fo fho buffor, fhoroby ovorInIng
rocossor oxocufIon wIfh momory udnfIng.
Tho dnfn nro nof noodod on n wrIfo, fhoro nro fwo nro fwo ofIons on n wrIfo mIss:
Write ullocute Tho bIock Is nIIocnfod on n wrIfo mIss, foIIowod by fho wrIfo
hIf ncfIons nbovo. In fhIs nnfurnI ofIon, wrIfo mIssos ncf IIko rond mIssos.
o-urite ullocuteThIs nnronfIy unusunI nIfornnfIvo Is wrIfo mIssos do noI
nffocf fho cncho. Insfond, fho bIock Is modIfIod onIy In fho Iowor IovoI momory.

4.3 CACH PRIORMANC

A boffor monsuro of momory-hIornrchy orformnnco Is fho uteruge memory
ucceoo time:
Avorngo momory nccoss fImo = HIf fImo + MIss rnfo MIss onnIfy

whoro Hit time Is fho fImo fo hIf In fho cncho; wo hnvo soon fho ofhor fwo forms boforo.

MIss vute Is

Tho nvorngo momory nccoss fImo formuIn cnn bo dIvIdod Info InsfrucfIon nnd dnfn
nccossos:




Computev AvcLItectuve
TLunguveI Muvugun 196

Avevuge memovy uccess tIme und Pvocessov PevIovmunce
Whofhor nvorngo momory nccoss fImo duo fo cncho mIssos rodIcfs rocossor
orformnnco`
IIrsf, fhoro nro ofhor ronsons for sfnIIs, such ns confonfIon duo fo I/O dovIcos
usIng momory. osIgnors offon nssumo fhnf nII momory sfnIIs nro duo fo cncho mIssos,
sInco fho momory hIornrchy fyIcnIIy domInnfos ofhor ronsons for sfnIIs.
Socond, fho nnswor doonds nIso on fho CI!. If wo hnvo nn In-ordor oxocufIon
CI!, fhon fho nnswor Is bnsIcnIIy yos. Tho CI! sfnIIs durIng mIssos, nnd fho momory
sfnII fImo Is sfrongIy corroInfod fo nvorngo momory nccoss fImo.

CPU tIme us:

CI! fImo = (CI! oxocufIon cIock cycIos + Momory sfnII cIock cycIos) CIock cycIo fImo



Cncho mIssos hnvo n doubIo-bnrroIod Imncf on n CI! wIfh n Iow CII nnd n fnsf cIock:

l. Tho Iowor fho CIIoxocufIon, fho hIghor fho reloIite Imncf of n fIxod numbor of cncho
mIss cIock cycIos.
2. Whon cnIcuInfIng CII, fho cncho mIss onnIfy Is monsurod In CI! cIock cycIos for n
mIss.

Avevuge memovy uccess tIme:
Avorngo momory nccoss fImo = HIf fImo + MIss rnfo MIss onnIfy



Computev AvcLItectuve
TLunguveI Muvugun 19?

Tho nvorngo momory nccoss fImo Is boffor for fho fwo-wny sof-nssocInfIvo cncho. CI!
orformnnco Is


MIss PenuIty und Out-oI-Ovdev ecutIon Pvocessovs
Momory sfnIIs fo Iond fo n now dofInIfIon of mIss onnIfy ns nonovorInod Infoncy:


Length of memory lutency: whnf fo consIdor ns fho sfnrf nnd fho ond of n momory
oornfIon In nn ouf-of-ordor rocossor; nnd
Length of lutency oterlup: whnf Is fho sfnrf of ovorIn wIfh for fho rocossor (or
oquIvnIonfIy, whon do wo sny n momory oornfIon Is sfnIIIng fho rocossor).

ImpvovIng CucLe PevIovmunce
Tho IncronsIng gn bofwoon CI! nnd mnIn momory soods hns nffrncfod fho
nffonfIon of mnny nrchIfocfs.
Tho nvorngo momory nccoss fImo formuIn:
Avorngo momory nccoss fImo = HIf fImo + MIss rnfo MIss onnIfy

l? cncho ofImIznfIons Info four cnfogorIos:
!oducIng fho mIss onnIfy: muIfIIovoI cnchos, crIfIcnI word fIrsf, rond mIss boforo
wrIfo mIss, morgIng wrIfo buffors, vIcfIm cnchos;
!oducIng fho mIss rnfo: Inrgor bIock sIzo, Inrgor cncho sIzo, nnd hIghor
nssocInfIvIfy, soudo-nssocInfIvIfy, nnd comIIor ofImIznfIons;
Computev AvcLItectuve
TLunguveI Muvugun 19B
!oducIng fho mIss onnIfy or mIss rnfo vIn nrnIIoIIsm: nonbIockIng cnchos,
hnrdwnro rofofchIng, nnd comIIor rofofchIng;
!oducIng fho fImo fo hIf In fho cncho: smnII nnd sImIo cnchos,nvoIdIng nddross
frnnsInfIon, nnd IoIInod cncho nccoss.


Summuvy oI pevIovmunce equutIons

4.4 RUCING CACH MISS PNAITY
!oducIng cncho mIssos hns boon fho frndIfIonnI focus of cncho rosonrch, buf fho
cncho orformnnco formuIn nssuros us fhnf Imrovomonfs In mIss onnIfy cnn bo jusf
ns bonofIcInI ns Imrovomonfs In mIss rnfo.

IIve optImIzutIons uddvess tLe IncveusIng mIss penuIty.
Tho mosf InforosfIng ofImIznfIon Is fho fIrsf, whIch ndds moro IovoIs of cnchos fo
roduco mIss onnIfy.


Computev AvcLItectuve
TLunguveI Muvugun 199
I) IIvst MIss PenuIty ReductIon TecLnIque: MuItI-IeveI CucLes
Tho IIrsf MIss IonnIfy !oducfIon TochnIquo foIIows fho AddIng nnofhor IovoI of cncho
bofwoon fho orIgInnI cncho nnd momory. Tho fIrsf-IovoI cncho cnn bo smnII onough fo
mnfch fho cIock cycIo fImo of fho fnsf CI! nnd fho socond-IovoI cncho cnn bo Inrgo
onough fo cnfuro mnny nccossos fhnf wouId go fo mnIn momory, fhoroby fho offocfIvo
mIss onnIfy.


Tho dofInIfIon of oteroge nenor, occeee Iine for n fwo-IovoI cncho. !sIng fho
subscrIfs !l nnd !2 fo rofor, rosocfIvoIy, fo n fIrsf-IovoI nnd n socond-IovoI cncho, fho
formuIn Is
Avorngo momory nccoss fImo = HIf fImo
!l
+ MIss rnfo
!l
MIss onnIfy
!l

And
MIss onnIfy
!l
= HIf fImo
!2
+ MIss rnfo
!2
MIss onnIfy
!2

So,
Avorngo momory nccoss fImo = HIf fImo
!l
+ MIss rnfo
!l

(HIf fImo
!2
+ MIss rnfo
!2
MIss onnIfy
!2
)
To nvoId nmbIguIfy, fhoso forms nro ndofod horo for n fwo-IovoI cncho sysfom:
Locul mioo ruteThIs rnfo Is sImIy fho numbor of mIssos In n cncho dIvIdod by fho
fofnI numbor of momory nccossos fo fhIs cncho. As you wouId oxocf, for fho fIrsf-IovoI
cncho If Is oqunI fo MIss rnfo
!l
nnd for fho socond-IovoI cncho If Is MIss rnfo
!2
.
Memory
disk
L1 cache
Regs
L2 cache
Processor
Computev AvcLItectuve
TLunguveI Muvugun 200
Clobul mioo ruteTho numbor of mIssos In fho cncho dIvIdod by fho fofnI num-bor of
momory nccossos gonornfod by fho CI!. !sIng fho forms nbovo, fho gIobnI mIss rnfo for
fho fIrsf-IovoI cncho Is sfIII jusf MIss rnfo
!l
buf for fho socond-IovoI cncho If Is MIss
rnfo
!l
MIss rnfo
!2
.
ThIs IocnI mIss rnfo Is Inrgo for socond IovoI cnchos bocnuso fho fIrsf-IovoI cncho
skIms fho cronm of fho momory nccossos.
ThIs Is why fho gIobnI mIss rnfo Is fho moro usofuI monsuro: If IndIcnfos whnf
frncfIon of fho momory nccossos fhnf Ionvo fho CI! go nII fho wny fo momory. Horo Is n
Inco whoro fho mIssos or InsfrucfIon mofrIc shInos. Insfond of confusIon nbouf IocnI or
gIobnI mIss rnfos, wo jusf oxnnd momory sfnIIs or InsfrucfIon fo ndd fho Imncf of n
socond IovoI cncho.

Avorngo momory sfnIIs or InsfrucfIon = MIssos or InsfrucfIon
!l
HIf fImo
!2
+ MIssos
or InsfrucfIon
!2
MIss onnIfy
!2
.

Wo cnn consIdor fho nrnmofors of socond-IovoI cnchos. Tho foromosf dIfforonco
bofwoon fho fwo IovoIs Is fhnf fho sood of fho fIrsf-IovoI cncho nffocfs fho cIock rnfo of
fho CI!, whIIo fho sood of fho socond-IovoI cncho onIy nffocfs fho mIss onnIfy of fho
fIrsf-IovoI cncho. Tho InIfInI docIsIon Is fho sIzo of n socond-IovoI cncho. SInco ovoryfhIng
In fho fIrsf-IovoI cncho Is IIkoIy fo bo In fho socond-IovoI cncho, fho socond-IovoI cncho
shouId bo much bIggor fhnn fho fIrsf. If socond-IovoI cnchos nro jusf n IIffIo bIggor, fho
IocnI mIss rnfo wIII bo hIgh. ow wo cnn roduco fho mIss onnIfy by roducIng fho niee
roIe of fho socond-IovoI cnchos.Anofhor consIdornfIon concorns whofhor dnfn In fho
fIrsf-IovoI cncho Is In fho socond-IovoI cncho.
Multiletel incluoion Is fho nnfurnI oIIcy for momory hIornrchIos: !l dnfn Is
nIwnys rosonf In !2. IncIusIon Is dosIrnbIo bocnuso consIsfoncy bofwoon I/O nnd cnchos
(or nmong cnchos In n muIfIrocossor) cnn bo doformInod jusf by chockIng fho socond-
IovoI cncho. Ono drnwbnck fo IncIusIon Is fhnf monsuromonfs cnn suggosf smnIIor
bIocks for fho smnIIor fIrsf-IovoI cncho nnd Inrgor bIocks for fho Inrgor socond-IovoI
cncho.
Computev AvcLItectuve
TLunguveI Muvugun 201

Tho socond-IovoI cncho musf InvnIIdnfo nII fIrsf-IovoI bIocks fhnf mn onfo fho
socond-IovoI bIock fo bo roIncod, cnusIng n sIIghfIy hIghor fIrsf-IovoI mIss rnfo. To
nvoId such robIoms, mnny cncho dosIgnors koo fho bIock sIzo fho snmo In nII IovoIs of
cnchos.
Multiletel ercluoion: !l dnfn Is neter found In !2 cncho. TyIcnIIy, wIfh
oxcIusIon n cncho mIss In !l rosuIfs In n swn of bIocks bofwoon !l nnd !2 Insfond of n
roIncomonf of n !l bIock wIfh n !2 bIock. ThIs oIIcy rovonfs wnsfIng snco In !2
cncho.

II) Second MIss PenuIty ReductIon TecLnIque: CvItIcuI Wovd IIvst und uvIy
Restuvt
MuIfIIovoI cnchos roquIro oxfrn hnrdwnro fo roduco mIss onnIfy, buf nof fhIs
socond fochnIquo. If Is bnsod on fho obsorvnfIon fhnf fho CI! normnIIy noods jusf ono
word of fho bIock nf n fImo. ThIs sfrnfogy Is ImnfIonco: on`f wnIf for fho fuII bIock fo
bo Iondod boforo sondIng fho roquosfod word nnd rosfnrfIng fho CI!. Horo nro fwo
socIfIc sfrnfogIos:
Criticul uorJ firot!oquosf fho mIssod word fIrsf from momory nnd sond If fo fho
CI! ns soon ns If nrrIvos; Iof fho CI! confInuo oxocufIon whIIo fIIIIng fho rosf of fho
words In fho bIock. CrIfIcnI-word-fIrsf fofch Is nIso cnIIod uroppeJ fofch nnd requeeIeJ
uorJ fireI.
Eurly reoturtIofch fho words In normnI ordor, buf ns soon ns fho roquosfod word of
fho bIock nrrIvos, sond If fo fho CI! nnd Iof fho CI! confInuo oxocufIon.
ConornIIy fhoso fochnIquos onIy bonofIf dosIgns wIfh Inrgo cncho bIocks, sInco
fho bonofIf Is Iow unIoss bIocks nro Inrgo. Tho robIom Is fhnf gIvon snfInI IocnIIfy,
fhoro Is moro fhnn rnndom chnnco fhnf fho noxf mIss Is fo fho romnIndor of fho bIock.
In such cnsos, fho offocfIvo mIss onnIfy Is fho fImo from fho mIss unfII fho socond Ioco
nrrIvos.
Computev AvcLItectuve
TLunguveI Muvugun 202
III) TLIvd MIss PenuIty ReductIon TecLnIque: GIvIng PvIovIty to Reud MIsses
ovev WvItes
ThIs ofImIznfIon sorvos ronds boforo wrIfos hnvo boon comIofod. Wo sfnrf wIfh
IookIng nf comIoxIfIos of n wrIfo buffor. WIfh n wrIfo-fhrough cncho fho mosf
Imorfnnf Imrovomonf Is n wrIfo buffor of fho roor sIzo.
WrIfo buffors, howovor, do comIIcnfo momory nccossos In fhnf fhoy mIghf hoId
fho udnfod vnIuo of n IocnfIon noodod on n rond mIss. Tho sImIosf wny ouf of fhIs Is
for fho rond mIss fo wnIf unfII fho wrIfo buffor Is omfy. Tho nIfornnfIvo Is fo chock fho
confonfs of fho wrIfo buffor on n rond mIss, nnd If fhoro nro no confIIcfs nnd fho momory
sysfom Is nvnIInbIo, Iof fho rond mIss confInuo. VIrfunIIy nII doskfo nnd sorvor
rocossors uso fho Inffor nronch, gIvIng ronds rIorIfy ovor wrIfos.

Tho cosf of wrIfos by fho rocossor In n wrIfo-bnck cncho cnn nIso bo roducod.
Suoso n rond mIss wIII roInco n dIrfy momory bIock. Insfond of wrIfIng fho dIrfy
bIock fo momory, nnd fhon rondIng momory, wo couId coy fho dIrfy bIock fo n buffor,
fhon rond momory, nnd IIen wrIfo momory.
ThIs wny fho CI! rond, for whIch fho rocossor Is robnbIy wnIfIng, wIII fInIsh
soonor. SImIInr fo fho sIfunfIon nbovo, If n rond mIss occurs, fho rocossor cnn oIfhor
sfnII unfII fho buffor Is omfy or chock fho nddrossos of fho words In fho buffor for
confIIcfs.
Iv) IouvtL MIss PenuIty ReductIon TecLnIque: MevgIng WvIte BuIIev
ThIs fochnIquo nIso InvoIvos wrIfo buffors, fhIs fImo ImrovIng fhoIr offIcIoncy.
WrIfo fhrough cnchos roIy on wrIfo buffors, ns nII sforos musf bo sonf fo fho noxf Iowor
IovoI of fho hIornrchy. As monfIonod nbovo, ovon wrIfo bnck cnchos uso n sImIo buffor
whon n bIock Is roIncod. If fho wrIfo buffor Is omfy, fho dnfn nnd fho fuII nddross nro
wrIffon In fho buffor, nnd fho wrIfo Is fInIshod from fho CI!'s orsocfIvo; fho CI!
confInuos workIng whIIo fho wrIfo buffor ronros fo wrIfo fho word fo momory.

Computev AvcLItectuve
TLunguveI Muvugun 203
If fho buffor confnIns ofhor modIfIod bIocks, fho nddrossos cnn bo chockod fo soo
If fho nddross of fhIs now dnfn mnfchos fho nddross of fho vnIId wrIfo buffor onfry. If so,
fho now dnfn nro combInod wIfh fhnf onfry, cnIIod urite merging. If fho buffor Is fuII
nnd fhoro Is no nddross mnfch, fho cncho (nnd CI!) musf wnIf unfII fho buffor hns nn
omfy onfry. ThIs ofImIznfIon usos fho momory moro offIcIonfIy sInco muIfIword
wrIfos nro usunIIy fnsfor fhnn wrIfos orformod ono word nf n fImo.


To IIIustvute wvIte mevgIng, tLe wvIte buIIev on top does not use It wLIIe tLe
wvIte buIIev on tLe bottom does.
Tho ofImIznfIon nIso roducos sfnIIs duo fo fho wrIfo buffor boIng fuII. IIguro
shows n wrIfo buffor wIfh nnd wIfhouf wrIfo morgIng. Assumo wo hnd four onfrIos In
fho wrIfo buffor, nnd onch onfry couId hoId four 64-bIf words. WIfhouf fhIs ofImIznfIon,
four sforos fo soquonfInI nddrossos wouId fIII fho buffor nf ono word or onfry, ovon
fhough fhoso four words whon morgod oxncfIy fIf wIfhIn n sIngIo onfry of fho wrIfo
buffor. IIguro To IIIusfrnfo wrIfo morgIng, fho wrIfo buffor on fo doos nof uso If whIIo
fho wrIfo buffor on fho boffom doos.
Tho four wrIfos nro morgod Info n sIngIo buffor onfry wIfh wrIfo morgIng;
wIfhouf If, fho buffor Is fuII ovon fhough fhroo-fourfhs of onch onfry Is wnsfod. Tho
buffor hns four onfrIos, nnd onch onfry hoIds four 64-bIf words. Tho nddross for onch
onfry Is on fho Ioff, wIfh vnIId bIfs (V) IndIcnfIng whofhor or nof fho noxf soquonfInI
oIghf byfos nro occuIod In fhIs onfry.
Computev AvcLItectuve
TLunguveI Muvugun 204
(WIfhouf wrIfo morgIng, fho words fo fho rIghf In fho uor drnwIng wouId onIy
bo usod for InsfrucfIons whIch wrofo muIfIIo words nf fho snmo fImo.)

v) IIItL MIss PenuIty ReductIon TecLnIque: VIctIm CucLes


Ono nronch fo Iowor mIss onnIfy Is fo romombor whnf wns dIscnrdod In cnso
If Is noodod ngnIn. SInco fho dIscnrdod dnfn hns nIrondy boon fofchod, If cnn bo usod
ngnIn nf smnII cosf.
Such rocycIIng roquIros n smnII, fuIIy nssocInfIvo cncho bofwoon n cncho nnd Ifs
rofIII nfh. IIguro 5.l3 shows fho orgnnIznfIon. ThIs ticIin cocIe confnIns onIy bIocks
fhnf nro dIscnrdod from n cncho bocnuso of n mIss vIcfIms nnd nro chockod on n mIss
fo soo If fhoy hnvo fho dosIrod dnfn boforo goIng fo fho noxf Iowor-IovoI momory. If If Is
found fhoro, fho vIcfIm bIock nnd cncho bIock nro swnod. Tho AM AfhIon hns n
vIcfIm cncho wIfh oIghf onfrIos.
JouI |l990] found fhnf vIcfIm cnchos of ono fo fIvo onfrIos nro offocfIvo nf
roducIng mIssos, osocInIIy for smnII, dIrocf-mnod dnfn cnchos. oondIng on fho
rogrnm, n four-onfry vIcfIm cncho mIghf romovo ono qunrfor of fho mIssos In n 4-KI
dIrocf-mnod dnfn cncho.

PIucement oI vIctIm cucLe In tLe memovy LIevuvcLy.
Computev AvcLItectuve
TLunguveI Muvugun 205
Summuvy oI MIss PenuIty ReductIon TecLnIques
Tho frsf fochnIquo foIIows fho rovorb fho moro fho morrIor: nssumIng fho rIncIIo
of IocnIIfy wIII koo nIyIng rocursIvoIy, jusf koo nddIng moro IovoIs of IncronsIngIy
Inrgor cnchos unfII you nro hny. Tho socond fochnIquo Is ImnfIonco: If rofrIovos fho
word of fho bIock fhnf cnusod fho mIss rnfhor fhnn wnIfIng for fho fuII bIock fo nrrIvo.
Tho noxf fochnIquo Is roforonco. If gIvos rIorIfy fo ronds ovor wrIfos sInco fho
rocossor gonornIIy wnIfs for ronds buf confInuos nffor InunchIng wrIfos. Tho fourfh
fochnIquo Is comnnIon-shI, combInIng wrIfos fo soquonfInI words Info n sIngIo bIock
fo cronfo n moro offIcIonf frnnsfor fo momory. IInnIIy comos n cncho oquIvnIonf of
rocycIIng, ns n vIcfIm cncho koos n fow dIscnrdod bIocks nvnIInbIo for whon fho fIckIo
rImnry cncho wnnfs n word fhnf If roconfIy dIscnrdod. AII fhoso fochnIquos hoI wIfh
mIss onnIfy, buf muIfIIovoI cnchos nro robnbIy fho mosf Imorfnnf.

4.5 RUCING MISS RAT
Tho cInssIcnI nronch fo ImrovIng cncho bohnvIor Is fo roduco mIss rnfos, nnd fhoro
nro fIvo fochnIquos fo roduco mIss rnfo. wo frsf sfnrf wIfh n modoI fhnf sorfs nII mIssos
Info fhroo sImIo cnfogorIos:
CompulooryTho vory fIrsf nccoss fo n bIock connoI Ie In fho cncho, so fho bIock musf
bo broughf Info fho cncho. Thoso nro nIso cnIIod colJ eIorI nieeee or fireI reference
nieeee.
CupucityIf fho cncho cnnnof confnIn nII fho bIocks noodod durIng oxocufIon of n
rogrnm, cnncIfy mIssos (In nddIfIon fo comuIsory mIssos) wIII occur bo-cnuso of
bIocks boIng dIscnrdod nnd Infor rofrIovod.
ConictIf fho bIock Incomonf sfrnfogy Is sof nssocInfIvo or dIrocf mnod, conIcf
mIssos (In nddIfIon fo comuIsory nnd cnncIfy mIssos) wIII occur bo-cnuso n bIock mny
bo dIscnrdod nnd Infor rofrIovod If foo mnny bIocks mn fo Ifs sof. Thoso mIssos nro nIso
cnIIod collieion nieeee or inIerference nieeee. Tho Idon Is fhnf hIfs In n fuIIy nssocInfIvo
cncho whIch bocomo mIssos In nn -wny sof nssocInfIvo cncho nro duo fo moro fhnn
roquosfs on somo ouInr sofs.
Computev AvcLItectuve
TLunguveI Muvugun 206
ComuIsory mIssos nro fhoso fhnf occur In nn InfInIfo cncho. CnncIfy mIssos nro
fhoso fhnf occur In n fuIIy nssocInfIvo cncho. ConfIIcf mIssos nro fhoso fhnf occur goIng
from fuIIy nssocInfIvo fo 8-wny nssocInfIvo, 4-wny nssocInfIvo, nnd so on.
To show fho bonofIf of nssocInfIvIfy, confIIcf mIssos nro dIvIdod Info mIssos
cnusod by onch docronso In nssocInfIvIfy. Horo nro fho four dIvIsIons of confIIcf mIssos
nnd how fhoy nro cnIcuInfod:
1igII-uo,confIIcf mIssos duo fo goIng from fuIIy nssocInfIvo (no confIIcfs) fo
oIghf-wny nssocInfIvo
Iour-uo,confIIcf mIssos duo fo goIng from oIghf-wny nssocInfIvo fo fourwny
nssocInfIvo
Tuo-uo,confIIcf mIssos duo fo goIng from four-wny nssocInfIvo fo fwo-wny
nssocInfIvo
One-uo,confIIcf mIssos duo fo goIng from fwo-wny nssocInfIvo fo ono-wny
nssocInfIvo (dIrocf mnod)
ConcofunIIy, confIIcfs nro fho onsIosf: IuIIy nssocInfIvo Incomonf nvoIds nII
confIIcf mIssos. IuII nssocInfIvIfy Is oxonsIvo In hnrdwnro, howovor, nnd mny sIow fho
rocossor cIock rnfo, IondIng fo Iowor ovornII orformnnco.
If fho uor-IovoI momory Is much smnIIor fhnn whnf Is noodod for n rogrnm,
nnd n sIgnIfIcnnf orconfngo of fho fImo Is sonf movIng dnfn bofwoon fwo IovoIs In fho
hIornrchy, fho momory hIornrchy Is snId fo thruoh.

I ) IIvst MIss Rute ReductIon TecLnIque: Iuvgev BIock SIze
Tho sImIosf wny fo roduco mIss rnfo Is fo Incronso fho bIock sIzo. IIguro shows
fho frndo-off of bIock sIzo vorsus mIss rnfo for n sof of rogrnms nnd cncho sIzos. !nrgor
bIock sIzos wIII roduco comuIsory mIssos. ThIs roducfIon occurs bocnuso fho rIncIIo
of IocnIIfy hns fwo comononfs: fomornI IocnIIfy nnd snfInI IocnIIfy. !nrgor bIocks
fnko ndvnnfngo of snfInI IocnIIfy.
Af fho snmo fImo, Inrgor bIocks Incronso fho mIss onnIfy. SInco fhoy roduco fho
numbor of bIocks In fho cncho, Inrgor bIocks mny Incronso confIIcf mIssos nnd ovon
cnncIfy mIssos If fho cncho Is smnII. CIonrIy, fhoro Is IIffIo ronson fo Incronso fho bIock
sIzo fo such n sIzo fhnf If increoeee fho mIss rnfo.
Computev AvcLItectuve
TLunguveI Muvugun 20?


MIss vute vevsus bIock sIze Iov IIve dIIIevent-sIzed cucLes.

Thoro Is nIso no bonofIf fo roducIng mIss rnfo If If Incronsos fho nvorngo momory
nccoss fImo. Tho Incronso In mIss onnIfy mny oufwoIgh fho docronso In mIss rnfo.
As In nII of fhoso fochnIquos, fho cncho dosIgnor Is fryIng fo mInImIzo bofh fho
mIss rnfo nnd fho mIss onnIfy. Tho soIocfIon of bIock sIzo doonds on bofh fho Infoncy
nnd bnndwIdfh of fho Iowor-IovoI momory.
HIgh Infoncy nnd hIgh bnndwIdfh oncourngo Inrgo bIock sIzo sInco fho cncho gofs
mnny moro byfos or mIss for n smnII Incronso In mIss onnIfy. ConvorsoIy, Iow Infoncy
nnd Iow bnndwIdfh oncourngo smnIIor bIock sIzos sInco fhoro Is IIffIo fImo snvod from n
Inrgor bIock.

II) Second MIss Rute ReductIon TecLnIque: Iuvgev CucLes
Tho obvIous wny fo roduco cnncIfy mIssos In fho nbovo Is fo Incronsos cnncIfy
of fho cncho. Tho obvIous drnwbnck Is Iongor hIf fImo nnd hIghor cosf. ThIs fochnIquo
hns boon osocInIIy ouInr In off-chI cnchos: Tho sIzo of socond or fhIrd IovoI cnchos In
200l oqunIs fho sIzo of mnIn momory In doskfo comufors.
Computev AvcLItectuve
TLunguveI Muvugun 20B
III) TLIvd MIss Rute ReductIon TecLnIque: HIgLev AssocIutIvIty
ConornIIy fho mIss rnfos Imrovos wIfh hIghor nssocInfIvIfy. Thoro nro fwo
gonornI ruIos of fhumb fhnf cnn bo drnwn. Tho fIrsf Is fhnf oIghf-wny sof nssocInfIvo Is
for rncfIcnI urosos ns offocfIvo In roducIng mIssos for fhoso sIzod cnchos ns fuIIy
nssocInfIvo.
You cnn soo fho dIfforonco by comnrIng fho 8-wny onfrIos fo fho cnncIfy mIss,
sInco cnncIfy mIssos nro cnIcuInfod usIng fuIIy nssocInfIvo cncho.
Tho socond obsorvnfIon, cnIIod fho 2.1 cocIe rule of IIunI nnd found on fho fronf
InsIdo covor, Is fhnf n dIrocf-mnod cncho of sIzo A hns nbouf fho snmo mIss rnfo ns n
2-wny sof-nssocInfIvo cncho of sIzo A/2. ThIs hoId for cncho sIzos Ioss fhnn l28 KI.

Iv) IouvtL MIss Rute ReductIon TecLnIque: Wuy PvedIctIon und Pseudo-
AssocIutIve CucLes
In uuy-preJiction, oxfrn bIfs nro kof In fho cncho fo rodIcf fho sof of fho nexI
cncho nccoss. ThIs rodIcfIon monns fho muIfIIoxor Is sof onrIy fo soIocf fho dosIrod
sof, nnd onIy n sIngIo fng comnrIson Is orformod fhnf cIock cycIo. A mIss rosuIfs In
chockIng fho ofhor sofs for mnfchos In subsoquonf cIock cycIos.
Tho AIhn 2l264 usos wny rodIcfIon In Ifs InsfrucfIon cncho. (Addod fo onch
bIock of fho InsfrucfIon cncho Is n sof rodIcfor bIf. Tho bIf Is usod fo soIocf whIch of fho
fwo sofs fo fry on fho nexI cncho nccoss. If fho rodIcfor Is corrocf, fho InsfrucfIon cncho
Infoncy Is ono cIock cycIo. If nof, If frIos fho ofhor sof, chnngos fho sof rodIcfor, nnd hns
n Infoncy of fhroo cIock cycIos. In nddIfIon fo ImrovIng orformnnco, wny rodIcfIon
cnn roduco owor for omboddod nIIcnfIons.
Iy onIy suIyIng owor fo fho hnIf of fho fngs fhnf nro oxocfod fo bo usod, fho
MIIS !4300 sorIos Iowors owor consumfIon wIfh fho snmo bonofIfs. A roInfod
nronch Is cnIIod poeuJo-uooociutite ov column uooociutite. Accossos rocood jusf
ns In fho dIrocf-mnod cncho for n hIf. On n mIss, howovor, boforo goIng fo fho noxf
Iowor IovoI of fho momory hIornrchy, n socond cncho onfry Is chockod fo soo If If mnfchos
fhoro. A sImIo wny Is fo Invorf fho mosf sIgnIfIcnnf bIf of fho Indox fIoId fo fInd fho
ofhor bIock In fho soudo sof.
Computev AvcLItectuve
TLunguveI Muvugun 209
Isoudo-nssocInfIvo cnchos fhon hnvo ono fnsf nnd ono sIow hIf fImo
corrosondIng fo n roguInr hIf nnd n soudo hIfIn nddIfIon fo fho mIss onnIfy. IIguro
shows fho roInfIvo fImos. Ono dnngor wouId bo If mnny fnsf hIf fImos of fho dIrocf-
mnod cncho bocnmo sIow hIf fImos In fho soudo-nssocInfIvo cncho. Tho orformnnco
wouId fhon bo JegroJeJ by fhIs ofImIznfIon. Honco, If Is Imorfnnf fo IndIcnfo for onch
sof whIch bIock shouId bo fho fnsf hIf nnd whIch shouId bo fho sIow ono. Ono wny Is
sImIy fo mnko fho uor ono fnsf nnd swn fho confonfs of fho bIocks. Anofhor dnngor
Is fhnf fho mIss onnIfy mny bocomo sIIghfIy Iongor, nddIng fho fImo fo chock nnofhor
cncho onfry.

ReIutIonsLIp between u veguIuv LIt tIme, pseudo LIt tIme, und mIss
penuIty.

v) IIItL MIss Rute ReductIon TecLnIque: CompIIev OptImIzutIons
ThIs fInnI fochnIquo roducos mIss rnfos wIfhouf nny hnrdwnro chnngos. ThIs
mngIcnI roducfIon comos from ofImIzod soffwnro. Tho IncronsIng orformnnco gn
bofwoon rocossors nnd mnIn momory hns InsIrod comIIor wrIfors fo scrufInIzo fho
momory hIornrchy fo soo If comIIo fImo ofImIznfIons cnn Imrovo orformnnco.
Onco ngnIn rosonrch Is sIIf bofwoon Imrovomonfs In InsfrucfIon mIssos nnd
Imrovomonfs In dnfn mIssos. Codo cnn onsIIy bo ronrrnngod wIfhouf nffocfIng
corrocfnoss; for oxnmIo, roordorIng fho rocoduros of n rogrnm mIghf roduco
InsfrucfIon mIss rnfos by roducIng confIIcf mIssos. !oordorIng fho InsfrucfIons roducod
mIssos by 50 for n 2-KI dIrocf-mnod InsfrucfIon cncho wIfh 4-byfo bIocks, nnd by
?5 In nn 8-KI cncho.

Computev AvcLItectuve
TLunguveI Muvugun 210
Anofhor codo ofImIznfIon nIms for boffor offIcIoncy from Iong cncho bIocks.
AIIgnIng bnsIc bIocks so fhnf fho onfry oInf Is nf fho bogInnIng of n cncho bIock
docronsos fho chnnco of n cncho mIss for soquonfInI codo.

Loop 1nterchunge:
Somo rogrnms hnvo nosfod Ioos fhnf nccoss dnfn In momory In non-soquonfInI
ordor. SImIy oxchnngIng fho nosfIng of fho Ioos cnn mnko fho codo nccoss fho dnfn In
fho ordor If Is sforod. AssumIng fho nrrnys do nof fIf In cncho, fhIs fochnIquo roducos
mIssos by ImrovIng snfInI IocnIIfy; roordorIng mnxImIzos uso of dnfn In n cncho bIock
boforo If Is dIscnrdod.
/* Ioforo */
for (j = 0; j < l00; j = j+l)
for (I = 0; I < 5000; I = I+l)
x|I]|j] = 2 * x|I]|j];
/* Affor */
for (I = 0; I < 5000; I = I+l)
for (j = 0; j < l00; j = j+l)
x|I]|j] = 2 * x|I]|j];

ThIs ofImIznfIon Imrovos cncho orformnnco wIfhouf nffocfIng fho numbor of
InsfrucfIons oxocufod.

Blocking:
ThIs ofImIznfIon frIos fo roduco mIssos vIn Imrovod fomornI IocnIIfy. Wo nro
ngnIn donIIng wIfh muIfIIo nrrnys, wIfh somo nrrnys nccossod by rows nnd somo by
coIumns. SforIng fho nrrnys row by row (rou nojor orJer) or coIumn by coIumn (colunn
nojor orJer) doos nof soIvo fho robIom bocnuso bofh rows nnd coIumns nro usod In
ovory IfornfIon of fho Ioo. Such orfhogonnI nccossos monn fho frnnsformnfIons such ns
Ioo Inforchnngo nro nof hoIfuI.

Computev AvcLItectuve
TLunguveI Muvugun 211
Insfond of oornfIng on onfIro rows or coIumns of nn nrrny, bIockod nIgorIfhms
oornfo on submnfrIcos or Ilocle. Tho gonI Is fo mnxImIzo nccossos fo fho dnfn Iondod
Info fho cncho boforo fho dnfn nro roIncod.
Summuvy oI ReducIng CucLe MIss Rute
ThIs socfIon fIrsf rosonfod fho fhroo C`s modoI of cncho mIssos: comuIsory,
cnncIfy, nnd confIIcf. ThIs InfuIfIvo modoI Iod fo fhroo obvIous ofImIznfIons: Inrgor
bIock sIzo fo roduco comuIsory mIssos, Inrgor cncho sIzo fo roduco cnncIfy mIssos, nnd
hIghor nssocInfIvIfy fo roduco confIIcf mIssos.
SInco hIghor nssocInfIvIfy mny nffocf cncho hIf fImo or cncho owor consumfIon,
wny rodIcfIon chocks onIy n Ioco of fho cncho for hIfs nnd fhon on n mIss chocks fho
rosf. Tho fInnI fochnIquo Is fho fnvorIfo of fho hnrdwnro dosIgnor, IonvIng cncho
ofImIznfIons fo fho comIIor.

4.6 RUCING CACH MISS PNAITY OR MISS RAT VIA
PARAIIIISM
Throo fochnIquos fhnf ovorIn fho oxocufIon of InsfrucfIons wIfh ncfIvIfy In fho
momory hIornrchy. Tho fIrsf cronfos n momory hIornrchy fo mnfch fho ouf-of-ordor
rocossors, buf fho socond nnd fhIrd work wIfh nny fyo of rocossor.

IIvst MIss PenuIty/Rute ReductIon TecLnIque: NonbIockIng CucLes to Reduce
StuIIs on CucLe MIsses
Ior IoIInod comufors fhnf nIIow ouf-of-ordor comIofIon, fho CI! nood nof
sfnII on n cncho mIss. A nonblocking cuche ov lockup-free cuche oscnInfos fho
ofonfInI bonofIfs of such n schomo by nIIowIng fho dnfn cncho fo confInuo fo suIy
cncho hIfs durIng n mIss. ThIs hIf undor mIss ofImIznfIon roducos fho offocfIvo mIss
onnIfy by boIng hoIfuI durIng n mIss Insfond of IgnorIng fho roquosfs of fho CI!.
A subfIo nnd comIox ofIon Is fhnf fho cncho mny furfhor Iowor fho offocfIvo
mIss onnIfy If If cnn ovorIn muIfIIo mIssos: n hIf undor muIfIIo mIss or mIss
undor mIss ofImIznfIon. Tho socond ofIon Is bonofIcInI onIy If fho momory sysfom cnn
sorvIco muIfIIo mIssos
Computev AvcLItectuve
TLunguveI Muvugun 212
IIonfIng-oInf rogrnms bonofIf from IncronsIng comIoxIfy, whIIo Infogor
rogrnms gof nImosf nII of fho bonofIf from n sImIo hIf-undor-ono-mIss schomo.Tho
ronI dIffIcuIfy wIfh orformnnco ovnIunfIon of nonbIockIng cnchos Is fhnf fhnf fhoy
ImIy n dynnmIc-Issuo CI!.
If Is dIffIcuIf fo judgo fho Imncf of nny sIngIo mIss, nnd honco dIffIcuIf fo
cnIcuInfo fho nvorngo momory nccoss fImo. As wns fho cnso of n socond mIss fo fho
romnInIng bIock wIfh crIfIcnI word fIrsf nbovo, fho offocfIvo mIss onnIfy Is nof fho sum
of fho mIssos buf fho non-ovorInod fImo fhnf fho CI! Is sfnIIod.
In gonornI, ouf-of-ordor CI!s nro cnnbIo of hIdIng fho mIss onnIfy of nn !l
dnfn cncho mIss whIch hIfs In fho !2 cncho, buf nof cnnbIo of hIdIng n sIgnIfIcnnf
frncfIon of nn !2 cncho mIssos. ChnngIng fho rogrnm fo IoIIno !2 mIssos cnn hoI,
osocInIIy fo n bnnkod momory sysfom.

Second MIss PenuIty/Rute ReductIon TecLnIque: Huvdwuve PveIetcLIng oI
InstvuctIons und utu
onbIockIng cnchos offocfIvoIy roduco fho mIss onnIfy by ovorInIng oxocufIon
wIfh momory nccoss. To hnvo vnIuo, wo nood n rocossor fhnf cnn nIIow InsfrucfIons fo
oxocufo ouf-of-ordor.
Anofhor nronch Is fo rofofch Ifoms boforo fhoy nro roquosfod by fho rocossor.
Iofh InsfrucfIons nnd dnfn cnn bo rofofchod, oIfhor dIrocfIy Info fho cnchos or Info nn
oxfornnI buffor fhnf cnn bo moro quIckIy nccossod fhnn mnIn momory.
InsfrucfIon rofofch Is froquonfIy dono In hnrdwnro oufsIdo of fho cncho.
TyIcnIIy, fho rocossor fofchos fwo bIocks on n mIss: fho roquosfod bIock nnd fho noxf
consocufIvo bIock. Tho roquosfod bIock Is Incod In fho InsfrucfIon cncho whon If
rofurns, nnd fho rofofchod bIock Is Incod Info fho InsfrucfIon sfronm buffor.
If fho roquosfod bIock Is rosonf In fho InsfrucfIon sfronm buffor, fho orIgInnI
cncho roquosf Is cnncoIod, fho bIock Is rond from fho sfronm buffor, nnd fho noxf
rofofch roquosf Is Issuod.
Avorngo momory nccoss fImorofofch = HIf fImo + MIss rnfo Irofofch hIf rnfo l +
MIss rnfo (l Irofofch hIf rnfo) MIss onnIfy

Computev AvcLItectuve
TLunguveI Muvugun 213
Avorngo momory nccoss fImo = HIf fImo + MIss rnfo MIss onnIfy



IrofofchIng roIIos on ufIIIzIng momory bnndwIdfh fhnf ofhorwIso wouId bo
unusod, buf If If Inforforos wIfh domnnd mIssos If cnn ncfunIIy Iowor orformnnco.

TLIvd MIss PenuIty/Rute ReductIon TecLnIque: CompIIev-ContvoIIed
PveIetcLIng

An nIfornnfIvo fo hnrdwnro rofofchIng Is for fho comIIor fo Insorf rofofch
InsfrucfIons fo roquosf fho dnfn boforo fhoy nro noodod. Thoro nro sovornI fInvors of
rofofch:
Regioter prefetch wIII Iond fho vnIuo Info n rogIsfor.
Cuche prefetch Ionds dnfn onIy Info fho cncho nnd nof fho rogIsfor.

IIfhor of fhoso cnn bo foulIing or nonfoulIing; fhnf Is, fho nddross doos or doos
nof cnuso nn oxcofIon for vIrfunI nddross fnuIfs nnd rofocfIon vIoInfIons. onfnuIfIng
rofofchos sImIy furn Info no-os If fhoy wouId normnIIy rosuIf In nn oxcofIon. !sIng
fhIs formInoIogy, n normnI Iond InsfrucfIon couId bo consIdorod n fnuIfIng rogIsfor
rofofch InsfrucfIon.Tho mosf offocfIvo rofofch Is somnnfIcnIIy InvIsIbIo fo n
rogrnm: If doosn'f chnngo fho confonfs of rogIsfors nnd momory onJ If cnnnof cnuso
vIrfunI momory fnuIfs. Mosf rocossors fodny offor non-fnuIfIng cncho rofofchos. ThIs
socfIon nssumos nonfnuIfIng cncho rofofch, nIso cnIIod nonIinJing rofofch.
IrofofchIng mnkos sonso onIy If fho rocossor cnn rocood whIIo fho rofofchod
dnfn nro boIng fofchod; fhnf Is, fho cnchos do nof sfnII buf confInuo fo suIy
InsfrucfIons nnd dnfn whIIo wnIfIng for fho rofofchod dnfn fo rofurn.
!Iko hnrdwnro-confroIIod rofofchIng, fho gonI Is fo ovorIn oxocufIon wIfh fho
rofofchIng of dnfn. !oos nro fho Imorfnnf fnrgofs, ns fhoy Iond fhomsoIvos fo
rofofch ofImIznfIons.
Computev AvcLItectuve
TLunguveI Muvugun 214
If fho mIss onnIfy Is smnII, fho comIIor jusf unroIIs fho Ioo onco or fwIco nnd
If schoduIos fho rofofchos wIfh fho oxocufIon. If fho mIss onnIfy Is Inrgo, If usos
soffwnro IoIInIng or unroIIs mnny fImos fo rofofch dnfn for n fufuro IfornfIon.

Summuvy oI ReducIng CucLe MIss PenuIty/ MIss Rute vIu PuvuIIeIIsm
In gonornI such rocossors cncho hIdo mIssos fo !l cnchos fhnf hIf In fho !2
cncho, buf nof n comIofo !2 cncho mIss. Howovor, If mIss undor mIss Is suorfod,
nonbIockIng cnchos cnn fnko ndvnnfngo of moro bnndwIdfh bohInd fho cncho by hnvIng
sovornI oufsfnndIng mIssos oornfIng nf onco for rogrnms wIfh suffIcIonf InsfrucfIon
IovoI nrnIIoIIsm.
Tho hnrdwnro nnd soffwnro rofofchIng fochnIquos Iovorngo oxcoss momory
bnndwIdfh for orformnnco by fryIng fo nnfIcInfo fho noods of n cncho.

4.? RUCING HIT TIM
HIf fImo Is crIfIcnI bocnuso If nffocfs fho cIock rnfo of fho rocossor. n fnsf hIf
fImo Is muIfIIIod In Imorfnnco boyond fho nvorngo momory nccoss fImo formuIn
bocnuso If hoIs ovoryfhIng.

IIvst HIt TIme ReductIon TecLnIque:SmuII und SImpIe CucLes
A fImo-consumIng orfIon of n cncho hIf Is usIng fho Indox orfIon of fho nddross
fo rond fho fng momory nnd fhon comnro If fo fho nddross. SmnIIor hnrdwnro Is fnsfor,
nnd n smnII cncho corfnInIy hoIs fho hIf fImo. If Is nIso crIfIcnI fo koo fho cncho smnII
onough fo fIf on fho snmo chI ns fho rocossor fo nvoId fho fImo onnIfy of goIng off-
chI. Tho socond suggosfIon Is fo koo fho cncho sImIo, such ns usIng dIrocf mnIng.
A mnIn bonofIf of dIrocf-mnod cnchos Is fhnf fho dosIgnor cnn ovorIn fho fng
chock wIfh fho frnnsmIssIon of fho dnfn. ThIs offocfIvoIy roducos hIf fImo. Honco, fho
rossuro of n fnsf cIock cycIo oncourngos smnII nnd sImIo cncho dosIgns for fIrsf-IovoI
cnchos. Ior socond IovoI cnchos, somo dosIgns sfrIko n comromIso by kooIng fho fngs
on-chI nnd fho dnfn off-chI, romIsIng n fnsf fng chock, yof rovIdIng fho gronfor
cnncIfy of sonrnfo momory chIs.

Computev AvcLItectuve
TLunguveI Muvugun 215

Second HIt TIme ReductIon TecLnIque: AvoIdIng Addvess TvunsIutIon duvIng
IndeIng oI tLe CucLe
Ivon n smnII nnd sImIo cncho musf coo wIfh fho frnnsInfIon of n vIrfunI
nddross from fho CI! fo n hysIcnI nddross fo nccoss momory. Irocossors fronf mnIn
momory ns jusf nnofhor IovoI of fho momory hIornrchy, nnd fhus fho nddross of fho
vIrfunI momory fhnf oxIsfs on dIsk musf bo mnod onfo fho mnIn momory.
Cnchos nro formod tirtuul cucheo, wIfh phyoicul cuche usod fo IdonfIfy fho
frndIfIonnI cncho fhnf usos hysIcnI nddrossos. If Is Imorfnnf fo dIsfInguIsh fwo fnsks:
IndoxIng fho cncho nnd fho comnrIng nddrossos.
A vIrfunI or hysIcnI nddross Is usod fo Indox fho cncho nnd whofhor n vIrfunI or
hysIcnI Indox Is usod In fho fng comnrIson. IuII vIrfunI nddrossIng for bofh Indox nnd
fngs oIImInnfos nddross frnnsInfIon fImo from n cncho hIf.
Ono ronson Is rofocfIon. Ingo IovoI rofocfIon Is chockod ns nrf of fho vIrfunI fo
hysIcnI nddross frnnsInfIon, nnd If musf bo onforcod no mnffor whnf. Anofhor ronson
Is fhnf ovory fImo n rocoss Is swIfchod, fho vIrfunI nddrossos rofor fo dIfforonf hysIcnI
nddrossos, roquIrIng fho cncho fo bo fIushod. Ono soIufIon Is fo Incronso fho wIdfh of fho
cncho nddross fng wIfh n proceoo-iJentifier tug (II). If fho oornfIng sysfom nssIgns
fhoso fngs fo rocossos, If onIy nood fIush fho cncho whon n II Is rocycIod; fhnf Is, fho
II dIsfInguIshos whofhor or nof fho dnfn In fho cncho nro for fhIs rogrnm.
VIrfunI cnchos nro nof moro ouInr Is fhnf oornfIng sysfoms nnd usor
rogrnms mny uso fwo dIfforonf vIrfunI nddrossos for fho snmo hysIcnI nddross. Thoso
duIIcnfo nddrossos, cnIIod oynonymo ov uliuoeo, couId rosuIf In fwo coIos of fho snmo
dnfn In n vIrfunI cncho; If ono Is modIfIod, fho ofhor wIII hnvo fho wrong vnIuo.
Hnrdwnro soIufIons fo fho synonym robIom, cnIIod unti-uliuoing, gunrnnfoo
ovory cncho bIock n unIquo hysIcnI nddross.
Soffwnro cnn mnko fhIs robIom much onsIor by forcIng nIInsos fo shnro somo
nddross bIfs. Tho vorsIon of !IX from Sun MIcrosysfoms, for oxnmIo, roquIros nII
nIInsos fo bo IdonfIcnI In fho Insf l8 bIfs of fhoIr nddrossos; fhIs rosfrIcfIon Is cnIIod
puge coloring.
Computev AvcLItectuve
TLunguveI Muvugun 216
Tho fInnI nron of concorn wIfh vIrfunI nddrossos Is I/O. I/O fyIcnIIy usos
hysIcnI nddrossos nnd fhus wouId roquIro mnIng fo vIrfunI nddrossos fo Inforncf
wIfh n vIrfunI cncho. Ono nIfornnfIvo fo gof fho bosf of bofh vIrfunI nnd hysIcnI cnchos
Is fo uso nrf of fho ngo offsoffho nrf fhnf Is IdonfIcnI In bofh vIrfunI nnd hysIcnI
nddrossos fo Indox fho cncho.
ThIs nIfornnfIvo nIIows fho cncho rond fo bogIn ImmodInfoIy nnd yof fho fng
comnrIson Is sfIII wIfh hysIcnI nddrossos. Tho IImIfnfIon of fhIs tirIuoll, inJexeJ,
pI,eicoll, IoggeJ nIfornnfIvo Is fhnf n dIrocf-mnod cncho cnn bo no bIggor fhnn fho
ngo sIzo.

SIze oI Inde Is contvoIIed by tLIs IovmuIu:


TLIvd HIt TIme ReductIon TecLnIque: PIpeIIned CucLe Access
Tho fInnI fochnIquo Is sImIy fo IoIIno cncho nccoss so fhnf fho offocfIvo Infoncy
of n fIrsf IovoI cncho hIf cnn bo muIfIIo cIock cycIos, gIvIng fnsf cycIo fImo nnd sIow
hIfs.
ThIs sIIf Incronsos fho numbor of IoIIno sfngos, IondIng fo gronfor onnIfy on
mIsrodIcfod brnnchos nnd moro cIock cycIos bofwoon fho Issuo of fho Iond nnd fho uso
of fho dnfn.

IouvtL HIt TIme ReductIon TecLnIque: Tvuce CucLes
A chnIIongo In fho offorf fo fInd InsfrucfIon IovoI nrnIIoIIsm boyond four
InsfrucfIons or cycIo Is fo suIy onough InsfrucfIons ovory cycIo wIfhouf
doondoncIos.
Ono soIufIon Is cnIIod n Iroce cocIe. Insfond of IImIfIng fho InsfrucfIons In n
sfnfIc cncho bIock fo snfInI IocnIIfy, n frnco cncho fInds n dynnmIc soquonco of
InsfrucfIons incluJing Iolen IroncIee fo Iond Info n cncho bIock.
Computev AvcLItectuve
TLunguveI Muvugun 21?
Tho nnmo comos from fho cncho bIocks confnInIng dynnmIc frncos of fho oxocufod
InsfrucfIons ns doformInod by fho CI! rnfhor fhnn confnInIng sfnfIc soquoncos of
InsfrucfIons ns doformInod by momory.
Trnco cnchos hnvo much moro comIIcnfod nddross mnIng mochnnIsms, ns fho
nddrossos nro no Iongor nIIgnod fo owor of 2 muIfIIo of fho word sIzo. Howovor, fhoy
hnvo ofhor bonofIfs for ufIIIznfIon of fho dnfn orfIon of fho InsfrucfIon cncho. Vory Iong
bIocks In convonfIonnI cnchos mny bo onforod from n fnkon brnnch, nnd honco fho fIrsf
orfIon of fho bIock wouId occuy snco In fho cncho mIghf nof bo fofchod. SImIInrIy,
such bIocks mny bo oxIfod by fnkon brnnchos, so fho Insf orfIon of fho bIock mIghf bo
wnsfod.
Trnco cnchos sforo InsfrucfIons onIy from fho brnnch onfry oInf fo fho oxIf of fho
frnco, fhoroby nvoIdIng such hondor nnd frnIIor ovorhond.

CucLe OptImIzutIon Summuvy
Tho fochnIquos In fo Imrovo mIss rnfo, mIss onnIfy, nnd hIf fImo gonornIIy
Imncf fho ofhor comononfs of fho nvorngo momory nccoss oqunfIon ns woII ns fho
comIoxIfy of fho momory hIornrchy.
Tho fochnIquos nnd osfImnfos fho Imncf on comIoxIfy, wIfh + monnIng fhnf fho
fochnIquo Imrovos fho fncfor, monnIng If hurfs fhnf fncfor, nnd bInnk monnIng If hns
no Imncf. ConornIIy no fochnIquo hoIs moro fhnn ono cnfogory.

4.B MAIN MMORY AN ORGANIZATIONS IOR IMPROVING
PRIORMANC
MnIn momory snfIsfIos fho domnnds of cnchos nnd sorvos ns fho I/O Inforfnco, ns
If Is fho dosfInnfIon of Inuf ns woII ns fho sourco for oufuf. Iorformnnco monsuros of
mnIn momory omhnsIzo bofh Infoncy nnd bnndwIdfh. (Momory bnndwIdfh Is fho
numbor of byfos rond or wrIffon or unIf fImo.)
TrndIfIonnIIy, mnIn momory Infoncy (whIch nffocfs fho cncho mIss onnIfy) Is fho
rImnry concorn of fho cncho, whIIo mnIn momory bnndwIdfh Is fho rImnry concorn of
I/O nnd muIfIrocossors.
Computev AvcLItectuve
TLunguveI Muvugun 21B
Cnchos nro Inforosfod In Iow Infoncy momory, If Is gonornIIy onsIor fo Imrovo
momory bnndwIdfh wIfh now orgnnIznfIons fhnn If Is fo roduco Infoncy. WIfh fho
ouInrIfy of socond-IovoI cnchos nnd fhoIr Inrgor bIock sIzos, mnIn momory bnndwIdfh
bocomos Imorfnnf fo cnchos ns woII. In fncf, cncho dosIgnors Incronso bIock sIzo fo fnko
ndvnnfngo of fho hIgh momory bnndwIdfh.InnovnfIvo orgnnIznfIons of mnIn momory
nro noodod ns woII.
Assumo fho orformnnco of fho bnsIc momory orgnnIznfIon Is
4 cIock cycIos fo sond fho nddross
56 cIock cycIos for fho nccoss fImo or word
4 cIock cycIos fo sond n word of dnfn
CIvon n cncho bIock of four words, nnd fhnf n word Is 8 byfos, fho mIss onnIfy Is 4
(4 + 56 + 4) or 256 cIock cycIos, wIfh n momory bnndwIdfh of ono-oIghfh byfo (32/256)
or cIock cycIo. Thoso vnIuos nro our dofnuIf cnso.

IIvst TecLnIque Iov HIgLev BundwIdtL: WIdev MuIn Memovy
IIrsf-IovoI cnchos nro offon orgnnIzod wIfh n hysIcnI wIdfh of ono word bocnuso
mosf CI! nccossos nro fhnf sIzo. oubIIng or qundruIIng fho wIdfh of fho cncho nnd
fho momory wIII fhoroforo doubIo or qundruIo fho momory bnndwIdfh.
WIfh n mnIn momory wIdfh of fwo words, fho mIss onnIfy In our oxnmIo wouId
dro from 4 64 or 256 cIock cycIos ns cnIcuInfod nbovo fo 2 64 or l28 cIock cycIos.
Tho ronson Is nf fwIco fho wIdfh wo nood hnIf fho momory nccossos nnd onch fnkos 64
cIock cycIos. Af four words wIdo fho mIss onnIfy Is jusf l 64 cIock cycIos.
Tho bnndwIdfh Is fhon ono-qunrfor byfo or cIock cycIo nf fwo words wIdo nnd
ono-hnIf byfo or cIock cycIo whon fho momory Is four words wIdo.Thoro Is cosf In fho
wIdor connocfIon bofwoon fho CI! nnd momory, fyIcnIIy cnIIod n momory Iue. Socond-
IovoI cnchos cnn hoI sInco fho muIfIIoxIng cnn bo bofwoon fIrsf- nnd socond-IovoI
cnchos, nof on fho crIfIcnI nfh.
SInco mnIn momory Is frndIfIonnIIy oxnndnbIo by fho cusfomor, n drnwbnck fo
wIdo momory Is fhnf fho mInImum Incromonf Is doubIod or qundruIod whon fho wIdfh
Is doubIod or qundruIod.
Computev AvcLItectuve
TLunguveI Muvugun 219
If fho orror corrocfIon Is dono ovor fho fuII wIdfh, fho wIdor momory wIII Incronso
fho froquoncy of such rond-modIfy-wrIfo soquoncos bocnuso moro wrIfos bocomo
nrfInI bIock wrIfos.

TLvee eumpIes oI bus wIdtL, memovy wIdtL, und memovy IntevIeuvIng to
ucLIeve LIgLev memovy bundwIdtL.
(n) Is fho sImIosf dosIgn, wIfh ovoryfhIng fho wIdfh of ono word;
(b) Shows n wIdor momory, bus, nnd !2 cncho wIfh n nnrrow !l cncho; whIIo
(c) Shows n nnrrow bus nnd cncho wIfh nn InforIonvod momory.

Second TecLnIque Iov HIgLev BundwIdtL: SImpIe IntevIeuved Memovy
IncronsIng wIdfh Is ono wny fo Imrovo bnndwIdfh, buf nnofhor Is fo fnko
ndvnnfngo of fho ofonfInI nrnIIoIIsm of hnvIng mnny chIs In n momory sysfom.
Momory chIs cnn bo orgnnIzod In Ionle fo rond or wrIfo muIfIIo words nf n fImo
rnfhor fhnn n sIngIo word.
In gonornI, fho uroso of InforIonvod momory Is fo fry fo fnko ndvnnfngo of fho
ofonfInI momory bnndwIdfh of oll fho chIs In fho sysfom; In confrnsf, mosf momory
sysfoms ncfIvnfo onIy fho chIs confnInIng fho noodod words.
Computev AvcLItectuve
TLunguveI Muvugun 220
Tho bnnks nro offon ono word wIdo so fhnf fho wIdfh of fho bus nnd fho cncho nood nof
chnngo, buf sondIng nddrossos fo sovornI bnnks ormIfs fhom nII fo rond
sImuIfnnoousIy. Innks nro nIso vnIunbIo on wrIfos.
AIfhough bnck-fo-bnck wrIfos wouId normnIIy hnvo fo wnIf for onrIIor wrIfos fo
fInIsh, bnnks nIIow ono cIock cycIo for onch wrIfo, rovIdod fho wrIfos nro nof dosfInod
fo fho snmo bnnk. Such n momory orgnnIznfIon Is osocInIIy Imorfnnf for wrIfo
fhrough.Tho mnIng of nddrossos fo bnnks nffocfs fho bohnvIor of fho momory sysfom.
Tho oxnmIo nbovo nssumos fho nddrossos of fho four bnnks nro InforIonvod nf fho word
IovoI: bnnk 0 hns nII words whoso nddross moduIo 4 Is 0, bnnk l hns nII words whoso
nddross moduIo 4 Is l, nnd so on. IIguro shows fhIs InforIonvIng.

Iouv-wuy IntevIeuved memovy
ThIs mnIng Is roforrod fo ns fho inIerleoting focIor; inIerleoteJ nenor,
normnIIy monns bnnks of momory fhnf nro word InforIonvod. ThIs InforIonvIng
ofImIzos soquonfInI momory nccossos. A cncho rond mIss Is nn IdonI mnfch fo word-
InforIonvod momory, ns fho words In n bIock nro rond soquonfInIIy. WrIfobnck cnchos
mnko wrIfos ns woII ns ronds soquonfInI, goffIng ovon moro offIcIoncy from word-
InforIonvod momory.

How muny bunks sLouId be IncIuded?
umbor of bnnks >=umbor of cIock cycIos fo nccoss word In bnnk
Wo nofo fhnf hnvIng mnny bnnks roducos fho chnnco of fhoso bnnk confIIcfs. As
cnncIfy or momory chI Incronsos, fhoro nro fowor chIs In fho snmo-sIzod momory
sysfom, mnkIng muIfIIo bnnks much moro oxonsIvo.
Computev AvcLItectuve
TLunguveI Muvugun 221
Mnny mnnufncfurors wIII wnnf fo hnvo n smnII momory ofIon In fho bnsoIIno
modoI. ThIs shrInkIng numbor of chIs Is fho mnIn dIsndvnnfngo of InforIonvod momory
bnnks. A socond dIsndvnnfngo of momory bnnks Is ngnIn fho dIffIcuIfy of mnIn momory
oxnnsIon.

TLIvd TecLnIque Iov HIgLev BundwIdtL: Independent Memovy Bunks
Tho orIgInnI mofIvnfIon for momory bnnks wns hIghor momory bnndwIdfh by
InforIonvIng soquonfInI nccossos. ThIs hnrdwnro Is nof much moro dIffIcuIf sInco fho
bnnks cnn shnro nddross IInos wIfh n momory confroIIor, onnbIIng onch bnnk fo uso fho
dnfn orfIon of fho momory bus.
A gonornIIznfIon of InforIonvIng Is fo nIIow muIfIIo Indoondonf nccossos, whoro
muIfIIo momory confroIIors nIIow bnnks (or sofs of word-InforIonvod bnnks) fo oornfo
IndoondonfIy. Inch bnnk noods sonrnfo nddross IInos nnd ossIbIy n sonrnfo dnfn
bus. onbIockIng cnchos nIIow fho CI! fo rocood boyond n cncho mIss, ofonfInIIy
nIIowIng muIfIIo cncho mIssos fo bo sorvIcod sImuIfnnoousIy. Such n dosIgn onIy
mnkos sonso wIfh momory bnnks; ofhorwIso fho muIfIIo ronds wIII bo sorvIcod by n
sIngIo momory orf nnd gof onIy n smnII bonofIf of ovorInIng nccoss wIfh
frnnsmIssIon.
Indoondonf of momory fochnoIogy, hIghor bnndwIdfh Is nvnIInbIo usIng momory
bnnks, by mnkIng momory nnd Ifs bus wIdor, or doIng bofh.











Computev AvcLItectuve
TLunguveI Muvugun 222

4.9 MMORY TCHNOIOGY
Momory Infoncy Is frndIfIonnIIy quofod usIng fwo monsurosnccoss fImo nnd
cycIo fImo. Acceee Iine Is fho fImo bofwoon whon n rond Is roquosfod nnd whon fho
dosIrod word nrrIvos, whIIo c,cle Iine Is fho mInImum fImo bofwoon roquosfs fo
momory. Ono ronson fhnf cycIo fImo Is gronfor fhnn nccoss fImo Is fhnf fho momory
noods fho nddross IInos fo bo sfnbIo bofwoon nccossos.

RAM tecLnoIogy
Tho mnIn momory of vIrfunIIy ovory doskfo or sorvor comufor Is comosod of
somIconducfor !AMs,. As onrIy !AMs grow In cnncIfy, fho cosf of n nckngo wIfh
nII fho nocossnry nddross IInos wns nn Issuo. Tho soIufIon wns fo muIfIIox fho nddross
IInos, fhoroby cuffIng fho numbor of nddross Ins In hnIf.
Ono hnIf of fho nddross Is sonf fIrsf, cnIIod fho rou occeee eIroIe or IAS. If Is
foIIowod by fho ofhor hnIf of fho nddross, sonf durIng fho colunn occeee eIroIe or CAS.
An nddIfIonnI roquIromonf of !AM dorIvos from fho roorfy sIgnIfIod by Ifs fIrsf
Ioffor, D, for J,nonic.
To nck moro bIfs or chI, !AMs uso onIy n sIngIo frnnsIsfor fo sforo n bIf.
!ondIng fhnf bIf cnn dIsfurb fho InformnfIon, howovor. To rovonf Ioss of InformnfIon,
onch bIf musf bo rofroshod orIodIcnIIy. IorfunnfoIy, nII fho bIfs In n row cnn bo
rofroshod sImuIfnnoousIy jusf by rondIng fhnf row. Honco, ovory !AM In fho momory
sysfom musf nccoss ovory row wIfhIn n corfnIn fImo wIndow. Momory confroIIors
IncIudo hnrdwnro fo orIodIcnIIy rofrosh fho !AMs.
ThIs roquIromonf monns fhnf fho momory sysfom Is occnsIonnIIy unnvnIInbIo
bocnuso If Is sondIng n sIgnnI foIIIng ovory chI fo refreeI. Tho fImo for n rofrosh Is
fyIcnIIy n fuII momory nccoss (!AS nnd CAS) for onch row of fho !AM.
SInco fho momory mnfrIx In n !AM Is concofunIIy squnro, fho numbor of sfos
In n rofrosh Is usunIIy fho squnro roof of fho !AM cnncIfy. !AM dosIgnors fry fo
koo fImo sonf rofroshIng fo bo Ioss fhnn 5 of fho fofnI fImo.
Computev AvcLItectuve
TLunguveI Muvugun 223

IntevnuI ovgunIzutIon oI u 64-MbIt RAM.
!AMs nro commonIy soId on smnII bonrds cnIIod D1MMe for Duol 1nline
Menor, MoJulee. IMMs fyIcnIIy confnIn 4 fo l6 !AMs. Thoy nro normnIIy
orgnnIzod fo bo oIghf byfos wIdo for doskfo sysfoms. In nddIfIon fo fho IMM
nckngIng nnd fho now Inforfncos fo Imrovo fho dnfn frnnsfor fImo, dIscussod In fho
foIIowIng subsocfIons, fho bIggosf chnngo fo !AMs hns boon n sIowIng down In
cnncIfy growfh.

SRAM TecLnoIogy
In confrnsf fo !AMs nro S!AMsfho fIrsf Ioffor sfnndIng for eIoIic. Tho
dynnmIc nnfuro of fho cIrcuIfs In !AM roquIro dnfn fo bo wrIffon bnck nffor boIng
rond, honco fho dIfforonco bofwoon fho nccoss fImo nnd fho cycIo fImo ns woII ns fho
nood fo rofrosh. S!AMs fyIcnIIy uso sIx frnnsIsfors or bIf fo rovonf fho InformnfIon
from boIng dIsfurbod whon rond.
ThIs dIfforonco In rofrosh nIono cnn mnko n dIfforonco for omboddod nIIcnfIons.
ovIcos offon go Info Iow owor or sfnndby modo for Iong orIods. S!AM noods onIy
mInImnI owor fo rofnIn fho chnrgo In sfnndby modo, buf !AMs musf confInuo fo bo
rofroshod occnsIonnIIy so ns fo nof Ioso InformnfIon.
In !AM dosIgns fho omhnsIs Is on cosf or bIf nnd cnncIfy, whIIo S!AM
dosIgns nro concornod wIfh sood nnd cnncIfy. (Iocnuso of fhIs concorn, S!AM nddross
IInos nro nof muIfIIoxod.).
Computev AvcLItectuve
TLunguveI Muvugun 224
Thus, unIIko !AMs, fhoro Is no dIfforonco bofwoon nccoss fImo nnd cycIo fImo.
Ior momorIos dosIgnod In comnrnbIo fochnoIogIos, fho cnncIfy of !AMs Is roughIy 4
fo 8 fImos fhnf of S!AMs. Tho cycIo fImo of S!AMs Is 8 fo l6 fImos fnsfor fhnn !AMs,
buf fhoy nro nIso 8 fo l6 fImos ns oxonsIvo.

mbedded Pvocessov Memovy TecLnoIogy: ROM und IIusL
Imboddod comufors usunIIy hnvo smnII momorIos, nnd mosf do nof hnvo n dIsk
fo ncf ns non-voInfIIo sforngo. Two momory fochnoIogIos nro found In omboddod
comufors fo nddross fhIs robIom.
Tho fIrsf Is IeoJ-Onl, Menor, (IOM). !OM Is rogrnmmod nf fImo of
mnnufncfuro, noodIng onIy n sIngIo frnnsIsfor or bIf fo rorosonf l or 0. !OM Is usod
for fho omboddod rogrnm nnd for consfnnfs, offon IncIudod ns nrf of n Inrgor chI.
In nddIfIon fo boIng non-voInfIIo, !OM Is nIso non-dosfrucfIbIo; nofhIng fho
comufor cnn modIfy fho confonfs of fhIs momory. Addross bnsod rofocfIon Is offon nof
onnbIod In omboddod rocossors; !OM cnn fuIfIII nn Imorfnnf roIo.
Tho socond momory fochnoIogy offors non-voInfIIIfy buf nIIows fho momory fo bo
modIfIod. IloeI nenor, nIIows fho omboddod dovIco fo nIfor nonvoInfIIo momory nffor
fho sysfom Is mnnufncfurod, whIch cnn shorfon roducf dovoIomonf.

ImpvovIng Memovy PevIovmunce In u stunduvd RAM CLIp
As Mooro`s !nw confInuos fo suIy moro frnnsIsfors nnd ns fho rocossor-
momory gn Incronsos rossuro on momory orformnnco. Tho Idon hns boon for gronfor
bnndwIdfh, offon nf fho cosf of gronfor Infoncy. ThIs subsocfIon rosonfs fochnIquos
fhnf fnko ndvnnfngo of fho nnfuro of !AMs.
A !AM nccoss Is dIvIdod Info row nccoss nnd coIumn nccoss. !AMs musf
buffor n row of bIfs InsIdo fho !AM for fho coIumn nccoss, nnd fhIs row Is usunIIy fho
squnro roof of fho !AM sIzo8 KbIfs for 64 MbIfs, l6 KbIfs for 256 MbIfs, nnd so on.
To Imrovo bnndwIdfh, fhoro hnvo boon n vnrIofy of ovoIufIonnry InnovnfIons
ovor fImo. Tho fIrsf wns fImIng sIgnnIs fhnf nIIow roonfod nccossos fo fho row buffor
wIfhouf nnofhor row nccoss fImo, fyIcnIIy cnIIod foeI poge noJe. Such n buffor comos
nnfurnIIy, ns onch nrrny wIII buffor l024 fo 2048 bIfs for onch nccoss.
Computev AvcLItectuve
TLunguveI Muvugun 225


Tho socond mnjor chnngo Is fhnf convonfIonnI !AMs hnvo nn nsynchronous
Inforfnco fo fho momory confroIIor, nnd honco ovory frnnsfor InvoIvos ovorhond fo
synchronIzo wIfh fho confroIIor.
Tho soIufIon wns fo ndd n cIock sIgnnI fo fho !AM Inforfnco, so fhnf fho
roonfod frnnsfors wouId nof bonr fhnf ovorhond. ThIs ofImIznfIon Is cnIIod
S,ncIronoue DIAM, nbbrovInfod SDIAM. S!AMs fyIcnIIy nIso hnvo n
rogrnmmnbIo rogIsfor fo hoId fho numbor of byfos roquosfod, nnd honco cnn sond
mnny byfos ovor sovornI cycIos or roquosf.
Tho fhIrd mnjor !AM InnovnfIon fo Incronso bnndwIdfh Is fo frnnsfor dnfn on
bofh fho rIsIng odgo nnd fnIIIng odgo of fho !AM cIock sIgnnI, fhoroby doubIIng fho
onk dnfn rnfo. ThIs ofImIznfIon Is cnIIod DouIle DoIo IoIe, nnd nbbrovInfod DDI.

ImpvovIng Memovy PevIovmunce vIu u new RAM IntevIuce: RAMBUS
Tho fIrsf gonornfIon !AMI!S Inforfnco drood !AS/CAS, roIncIng If wIfh n
bus fhnf nIIows ofhor nccossos ovor fho bus bofwoon fho sondIng of fho nddross nnd
rofurn of fho dnfn. If Is fyIcnIIy cnIIod IDIAM. (Such n bus Is cnIIod n pocleI-euiIcIeJ
Iue or epliI-IroneocIion bus). ThIs bus nIIows n sIngIo chI fo ncf ns n momory bnnk.
Tho socond gonornfIon !AMI!S Inforfnco, cnIIod DirecI IDIAM or DIDIAM,
offors u fo l.6 CIyfos/socond of bnndwIdfh from n sIngIo !AM. InnovnfIons In fhIs
Inforfnco IncIudo n sonrnfo row- nnd coIumn-commnnd busos Insfond of fho
convonfIonnI muIfIIoxIng; nn l8-bIf dnfn bus; oxnndIng from 4 fo l6 InfornnI bnnks
or !!AM fo roduco bnnk confIIcfs; IncronsIng fho numbor of row buffors from 4 fo 8;
IncronsIng fho cIock fo 400 MHz cIock; nnd n much moro sohIsfIcnfod confroIIor on
chI.
Iocnuso of fho sonrnfIon of dnfn, row, nnd coIumn busos, fhroo frnnsncfIons cnn
bo orformod sImuIfnnoousIy.



Computev AvcLItectuve
TLunguveI Muvugun 226
CompuvIng RAMBUS und R SRAM
How doos fho !AMI!S Inforfnco comnro In cosf nnd orformnnco whon Incod In n
sysfom`
Mosf mnIn momory sysfoms nIrondy uso S!AM fo gof moro bIfs or momory
nccoss, In fho hoo of roducIng fho CI!-!AM orformnnco gn.
SInco fho mosf comufors uso momory In IMM nckngos, whIch nro fyIcnIIy nf
Ionsf 64-bIfs wIdo, fho IMM momory bnndwIdfh Is cIosor fo whnf !AMI!S rovIdos
fhnn you mIghf oxocf whon jusf comnrIng !AM chIs.
In nddIfIon fo orformnnco, fho now broods of !AMs such ns !!AM nnd
!!AM hnvo rIco n romIum ovor frndIfIonnI !AMs fo rovIdo fho gronfor
bnndwIdfh sInco fhoso chIs nro Inrgor. Tho quosfIon ovor fImo Is how much moro.
Tho mnrkofInco wIII doformIno whofhor fho moro rndIcnI !AMs such ns
!AMI!S wIII bocomo ouInr for mnIn momory, or whofhor fho rIco romIum
rosfrIcfs fhom fo nIcho mnrkofs.

4.10 VIRTUAI MMORY
A monns of shnrIng n smnIIor nmounf of hysIcnI momory nmong mnny
rocossos. Ono wny fo do fhIs, tirIuol nenor, dIvIdos hysIcnI momory Info bIocks nnd
nIIocnfos fhom fo dIfforonf rocossos. An nronch musf bo n proIecIion schomo fhnf
rosfrIcfs n rocoss fo fho bIocks boIongIng onIy fo fhnf rocoss.
Irogrnmmors dIvIdod rogrnms Info Iocos, fhon IdonfIfIod fho Iocos fhnf woro
mufunIIy oxcIusIvo, nnd Iondod or unIondod fhoso oterlo,e undor usor rogrnm confroI
durIng oxocufIon.
VIrfunI momory wns Invonfod fo roIIovo rogrnmmors of fhIs burdon; If
nufomnfIcnIIy mnnngos fho fwo IovoIs of fho momory hIornrchy rorosonfod by mnIn
momory nnd socondnry sforngo.
In nddIfIon fo shnrIng rofocfod momory snco nnd nufomnfIcnIIy mnnngIng fho
momory hIornrchy, vIrfunI momory nIso sImIIfIos IondIng fho rogrnm for oxocufIon.
CnIIod relocoIion, fhIs mochnnIsm nIIows fho snmo rogrnm fo run In nny IocnfIon In
hysIcnI momory.

Computev AvcLItectuve
TLunguveI Muvugun 22?


Poge or eegnenI Is usod for bIock, nnd poge foulI or oJJreee foulI Is usod for
mIss. WIfh vIrfunI momory, fho CI! roducos tirIuol oJJreeeee fhnf nro frnnsInfod by
n combInnfIon of hnrdwnro nnd soffwnro fo pI,eicol oJJreeeee, whIch nccoss mnIn
momory. ThIs rocoss Is cnIIod nenor, nopping or oJJreee IroneloIion.

Thoro nro furfhor dIfforoncos bofwoon cnchos nnd vIrfunI momory boyond fhoso
qunnfIfnfIvo onos monfIonod:
!oIncomonf on cncho mIssos Is rImnrIIy confroIIod by hnrdwnro, whIIo vIrfunI
momory roIncomonf Is rImnrIIy confroIIod by fho oornfIng sysfom. Tho Iongor
mIss onnIfy monns If`s moro Imorfnnf fo mnko n good docIsIon, so fho
oornfIng sysfom cnn bo InvoIvod nnd sond fnko fImo docIdIng whnf fo roInco.
Tho sIzo of fho rocossor nddross doformInos fho sIzo of vIrfunI momory, buf fho
cncho sIzo Is Indoondonf of fho rocossor nddross sIzo.
In nddIfIon fo ncfIng ns fho Iowor-IovoI bnckIng sforo for mnIn momory In fho
hIornrchy, socondnry sforngo Is nIso usod for fho fIIo sysfom. In fncf, fho fIIo
sysfom occuIos mosf of socondnry sforngo. If Is nof normnIIy In fho nddross
snco.

VIrfunI momory sysfoms cnn bo cnfogorIzod Info fwo cInssos: fhoso wIfh fIxod-
sIzo bIocks, cnIIod pogee, nnd fhoso wIfh vnrInbIo-sIzo bIocks, cnIIod eegnenIe. Iocnuso
of fho roIncomonf robIom (fho fhIrd IIno of fho fIguro), fow comufors fodny uso uro
sogmonfnfIon. Somo comufors uso n hybrId nronch, cnIIod pogeJ eegnenIe, In whIch
n sogmonf Is nn InfogrnI numbor of ngos. ThIs sImIIfIos roIncomonf bocnuso momory
nood nof bo confIguous, nnd fho fuII sogmonfs nood nof bo In mnIn momory.





Computev AvcLItectuve
TLunguveI Muvugun 22B



TLe IogIcuI pvogvum In Its contIguous vIvtuuI uddvess spuce Is sLown on tLe
IeIt.


TypIcuI vunges oI puvumetevs Iov cucLes und vIvtuuI memovy.
Computev AvcLItectuve
TLunguveI Muvugun 229

PugIng vevsus segmentutIon.

umpIe oI Low pugIng und segmentutIon dIvIde u pvogvum.

Tho four momory-hIornrchy quosfIons for vIrfunI momory:
Q1: WLeve cun u bIock be pIuced In muIn memovy?
Tho mIss onnIfy for vIrfunI momory InvoIvos nccoss fo n rofnfIng mngnofIc
sforngo dovIco nnd Is fhoroforo quIfo hIgh. CIvon fho choIco of Iowor mIss rnfos or n
sImIor Incomonf nIgorIfhm, oornfIng sysfoms dosIgnors normnIIy Ick Iowor mIss
rnfos bocnuso of fho oxorbIfnnf mIss onnIfy. Thus, oornfIng sysfoms nIIow bIocks fo bo
Incod nnywhoro In mnIn momory

Q2: How Is u bIock Iound II It Is In muIn memovy?
Iofh ngIng nnd sogmonfnfIon roIy on n dnfn sfrucfuro fhnf Is Indoxod by fho
ngo or sogmonf numbor. ThIs dnfn sfrucfuro confnIns fho hysIcnI nddross of fho
bIock.

Computev AvcLItectuve
TLunguveI Muvugun 230
Ior sogmonfnfIon, fho offsof Is nddod fo fho sogmonf`s hysIcnI nddross fo obfnIn
fho fInnI hysIcnI nddross. Ior ngIng, fho offsof Is sImIy concnfonnfod fo fhIs hysIcnI
ngo nddross.ThIs dnfn sfrucfuro, confnInIng fho hysIcnI ngo nddrossos, usunIIy fnkos
fho form of n poge IoIle. Indoxod by fho vIrfunI ngo numbor, fho sIzo of fho fnbIo Is fho
numbor of ngos In fho vIrfunI nddross snco. CIvon n 32-bIf vIrfunI nddross, 4-KI
ngos, nnd 4 byfos or ngo fnbIo onfry, fho sIzo of fho ngo fnbIo wouId bo (232/2l2)
22 = 222 or 4 MI.
Tho hnsh nIIows fho dnfn sfrucfuro fo bo fho Iongfh of fho numbor of pI,eicol
ngos In mnIn momory. ThIs numbor couId bo much smnIIor fhnn fho numbor of vIrfunI
ngos. Such n sfrucfuro Is cnIIod nn interIeJ poge IoIle. To roduco nddross frnnsInfIon
fImo, comufors uso n cncho dodIcnfod fo fhoso nddross frnnsInfIons, cnIIod n
IroneloIion lool-oeiJe Iuffer, or sImIy IroneloIion Iuffer.

Q3: WLIcL bIock sLouId be vepIuced on u vIvtuuI memovy mIss?
Tho ovorrIdIng oornfIng sysfom guIdoIIno Is mInImIzIng ngo fnuIfs. ConsIsfonf
wIfh fhIs guIdoIIno, nImosf nII oornfIng sysfoms fry fo roInco fho Ionsf-roconfIy usod
(!!!) bIock, bocnuso If fho nsf rodIcfs fho fufuro, fhnf Is fho ono Ioss IIkoIy fo bo
noodod.
To hoI fho oornfIng sysfom osfImnfo !!!, mnny rocossors rovIdo n uee IiI or
reference IiI, whIch Is IogIcnIIy sof whonovor n ngo Is nccossod. Tho oornfIng sysfom
orIodIcnIIy cIonrs fho uso bIfs nnd Infor rocords fhom so If cnn doformIno whIch ngos
woro fouchod durIng n nrfIcuInr fImo orIod. Iy kooIng frnck In fhIs wny, fho
oornfIng sysfom cnn soIocf n ngo fhnf Is nmong fho Ionsf-roconfIy roforoncod.

Q4: WLut Luppens on u wvIte?
Tho IovoI boIow mnIn momory confnIns rofnfIng mngnofIc dIsks fhnf fnko
mIIIIons of cIock cycIos fo nccoss. Iocnuso of fho gronf dIscronncy In nccoss fImo, no ono
hns yof buIIf n vIrfunI momory oornfIng sysfom fhnf wrIfos fhrough mnIn momory fo
dIsk on ovory sforo by fho CI!. Thus, fho wrIfo sfrnfogy Is nIwnys wrIfo bnck. SInco fho
cosf of nn unnocossnry nccoss fo fho noxf-Iowor IovoI Is so hIgh, vIrfunI momory sysfoms
Computev AvcLItectuve
TLunguveI Muvugun 231
usunIIy IncIudo n dIrfy bIf. If nIIows bIocks fo bo wrIffon fo dIsk onIy If fhoy hnvo boon
nIforod sInco boIng rond from fho dIsk.

TecLnIques Iov Iust Addvess TvunsIutIon
Ingo fnbIos nro usunIIy so Inrgo fhnf fhoy nro sforod In mnIn momory, nnd somo-
fImos ngod fhomsoIvos. IngIng monns fhnf ovory momory nccoss IogIcnIIy fnkos nf
Ionsf fwIco ns Iong, wIfh ono momory nccoss fo obfnIn fho hysIcnI nddross nnd n socond
nccoss fo gof fho dnfn. ThIs cosf Is fnr foo donr.
Ono romody Is fo romombor fho Insf frnnsInfIon, so fhnf fho mnIng rocoss Is
skIod If fho curronf nddross rofors fo fho snmo ngo ns fho Insf ono. A moro gonornI
soIufIon Is fo ngnIn roIy on fho rIncIIo of IocnIIfy; If fho nccossos hnvo IocnIIfy, fhon
fho oJJreee IroneloIione for fho nccossos musf nIso hnvo IocnIIfy. Iy kooIng fhoso
nddross frnnsInfIons In n socInI cncho, n momory nccoss rnroIy ro-quIros n socond
nccoss fo frnnsInfo fho dnfn. ThIs socInI nddross frnnsInfIon cncho Is roforrod fo ns n
IroneloIion lool-oeiJe Iuffer or T!I, nIso cnIIod n IroneloIion Iuffer or TI.
A T!I onfry Is IIko n cncho onfry whoro fho fng hoIds orfIons of fho vIrfunI
nddross nnd fho dnfn orfIon hoIds n hysIcnI ngo frnmo numbor, rofocfIon fIoId,
vnIId bIf, nnd usunIIy n uso bIf nnd dIrfy bIf. To chnngo fho hysIcnI ngo frnmo numbor
or rofocfIon of nn onfry In fho ngo fnbIo, fho oornfIng sysfom musf mnko suro fho oId
onfry Is nof In fho T!I; ofhorwIso, fho sysfom won`f bo-hnvo roorIy.
ofo fhnf fhIs dIrfy bIf monns fho corrosondIng poge Is dIrfy, nof fhnf fho
nddross frnnsInfIon In fho T!I Is dIrfy nor fhnf n nrfIcuInr bIock In fho dnfn cncho Is
dIrfy. Tho oornfIng sysfom rosofs fhoso bIfs by chnngIng fho vnIuo In fho ngo fnbIo
nnd fhon InvnIIdnfIng fho corrosondIng T!I onfry.
Whon fho onfry Is roIondod from fho ngo fnbIo, fho T!I gofs nn nccurnfo coy of
fho bIfs. IIguro shows fho AIhn 2l264 dnfn T!I orgnnIznfIon, wIfh onch sfo of n
frnnsInfIon InboIod. Tho T!I usos fuIIy nssocInfIvo Incomonf; fhus, fho frnnsInfIon
bogIns (sfos l nnd 2) by sondIng fho vIrfunI nddross fo nII fngs.
Of courso, fho fng musf bo mnrkod vnIId fo nIIow n mnfch. Af fho snmo fImo, fho
fyo of momory nccoss Is chockod for n vIoInfIon (nIso In sfo 2) ngnInsf rofocfIon Infor-
mnfIon In fho T!I.
Computev AvcLItectuve
TLunguveI Muvugun 232

OpevutIon oI tLe AIpLu 21264 dutu TIB duvIng uddvess tvunsIutIon.
SeIectIng u Puge SIze
Tho mosf obvIous nrchIfocfurnI nrnmofor Is fho ngo sIzo. ChoosIng fho ngo Is
n quosfIon of bnInncIng forcos fhnf fnvor n Inrgor ngo sIzo vorsus fhoso fnvorIng n
smnIIor sIzo. Tho foIIowIng fnvor n Inrgor sIzo:
Tho sIzo of fho ngo fnbIo Is InvorsoIy roorfIonnI fo fho ngo sIzo; momory (or
ofhor rosourcos usod for fho momory mn) cnn fhoroforo bo snvod by mnkIng fho
ngos bIggor.
A Inrgor ngo sIzo cnn nIIow Inrgor cnchos wIfh fnsf cncho hIf fImos.
TrnnsforrIng Inrgor ngos fo or from socondnry sforngo, ossIbIy ovor n nofwork,
Is moro offIcIonf fhnn frnnsforrIng smnIIor ngos.
Tho numbor of T!I onfrIos nro rosfrIcfod, so n Inrgor ngo sIzo monns fhnf moro
momory cnn bo mnod offcIonfIy, fhoroby roducIng fho numbor of T!I mIssos.

Computev AvcLItectuve
TLunguveI Muvugun 233
4.11 PROTCTION AN XAMPIS OI VIRTUAI MMORY

MuIfIrogrnmmIng forcos fo worry nbouf usngo of vIrfunI momory. So IrofocfIon
Is roquIrod for vIrfunI momory concof. Tho rosonsIbIIIfy for mnInfnInIng corrocf
rocoss bohnvIor Is shnrod by dosIgnors of fho comufor nnd fho oornfIng sysfom. Tho
comufor dosIgnor musf onsuro fhnf fho CI! orfIon of fho rocoss sfnfo cnn bo snvod
nnd rosforod. Tho oornfIng sysfom dosIgnor musf gunrnnfoo fhnf rocossos do nof
Inforforo wIfh onch ofhors` comufnfIons.
Tho snfosf wny fo rofocf fho sfnfo of ono rocoss from nnofhor wouId bo fo coy
fho curronf InformnfIon fo dIsk. Howovor, n rocoss swIfch wouId fhon fnko soconds
fnr foo Iong for n fImo-shnrIng onvIronmonf. ThIs robIom Is soIvod by oornfIng
sysfoms nrfIfIonIng mnIn momory so fhnf sovornI dIfforonf rocossos hnvo fhoIr sfnfo
In momory nf fho snmo fImo.
PvotectIng Pvocesses
Tho sImIosf rofocfIon mochnnIsm Is n nIr of rogIsfors fhnf chocks ovory nd-
dross fo bo suro fhnf If fnIIs bofwoon fho fwo IImIfs, frndIfIonnIIy cnIIod Ioee nnd IounJ.
An nddross Is vnIId If
Buse Addvess Bound
In somo sysfoms, fho nddross Is consIdorod nn unsIgnod numbor fhnf Is nIwnys
nddod fo fho bnso, so fho IImIf fosf Is jusf
(Buse + Addvess) Bound
If usor rocossos nro nIIowod fo chnngo fho bnso nnd bounds rogIsfors, fhon usors
cnn`f bo rofocfod from onch ofhor. Tho oornfIng sysfom, howovor, musf bo nbIo fo
chnngo fho rogIsfors so fhnf If cnn swIfch rocossos. Honco, fho comufor dosIgnor hns
fhroo moro rosonsIbIIIfIos In hoIIng fho oornfIng sysfom dosIgnor rofocf rocossos
from onch ofhor:
IrovIdo nf Ionsf fwo modos, IndIcnfIng whofhor fho runnIng rocoss Is n usor
rocoss or nn oornfIng sysfom rocoss. ThIs Inffor rocoss Is somofImos cnIIod n
lernel rocoss, n eupertieor rocoss, or nn execuIite rocoss.
Computev AvcLItectuve
TLunguveI Muvugun 234
IrovIdo n orfIon of fho CI! sfnfo fhnf n usor rocoss cnn uso buf nof wrIfo.
ThIs sfnfo IncIudos fho bnso/bound rogIsfors, n usor/suorvIsor modo bIf(s), nnd
fho oxcofIon onnbIo/dIsnbIo bIf. !sors nro rovonfod from wrIfIng fhIs sfnfo
bocnuso fho oornfIng sysfom cnnnof confroI usor rocossos If usors cnn chnngo
fho nddross rnngo chocks, gIvo fhomsoIvos suorvIsor rIvIIogos, or dIsnbIo
oxcofIons.
IrovIdo mochnnIsms whoroby fho CI! cnn go from usor modo fo suorvIsor
modo nnd vIco vorsn. Tho fIrsf dIrocfIon Is fyIcnIIy nccomIIshod by n e,eIen
coll, ImIomonfod ns n socInI InsfrucfIon fhnf frnnsfors confroI fo n dodIcnfod
IocnfIon In suorvIsor codo snco. Tho IC Is snvod from fho oInf of fho sys-fom
cnII, nnd fho CI! Is Incod In suorvIsor modo. Tho rofurn fo usor modo Is IIko n
subroufIno rofurn fhnf rosforos fho rovIous usor/suorvIsor modo.

A Puged VIvtuuI Memovy umpIe: TLe AIpLu Memovy Munugement und tLe
21264 TIB
Tho AIhn nrchIfocfuro usos n combInnfIon of sogmonfnfIon nnd ngIng,
rovIdIng rofocfIon whIIo mInImIzIng ngo fnbIo sIzo. WIfh 48-bIf vIrfunI nddrossos,
fho 64-bIf nddross snco Is fIrsf dIvIdod Info fhroo sogmonfs: eeg0 (bIfs 63 - 4? = 0...00),
leeg (bIfs 63 - 46 = 0...l0), nnd eeg1 (bIfs 63 fo 46 = l...ll). ksog Is ro-sorvod for fho
oornfIng sysfom kornoI, hns unIform rofocfIon for fho whoIo snco, nnd doos nof uso
momory mnnngomonf.
!sor rocossos uso sog0, whIch Is mnod Info ngos wIfh IndIvIdunI rofocfIon.
IIguro shows fho Inyouf of sog0 nnd sogl. sog 0 grows from nddross 0 uwnrd, whIIo
sogl grows downwnrd fo 0. ThIs nronch rovIdos mnny ndvnnfngos: sogmonfnfIon
dIvIdos fho nddross snco nnd consorvos ngo fnbIo snco, whIIo ngIng rovIdos vIrfunI
momory, roIocnfIon, nnd rofocfIon.
Computev AvcLItectuve
TLunguveI Muvugun 235

TLe ovgunIzutIon oI seg0 und seg1 In tLe AIpLu.

Tho AIhn usos n fhroo-IovoI hIornrchIcnI ngo fnbIo fo mn fho nddross snco fo
koo fho sIzo ronsonnbIo. IIguro 5.39 shows nddross frnnsInfIon In fho AIhn. Tho
nddrossos for onch of fhoso ngo fnbIos como from fhroo IovoI fIoIds, InboIod IovoIl,
IovoI2, nnd IovoI3.

Addross frnnsInfIon sfnrfs wIfh nddIng fho IovoIl nddross fIoId fo fho ngo fnbIo
bnso rogIsfor nnd fhon rondIng momory from fhIs IocnfIon fo gof fho bnso of fho socond-
IovoI ngo fnbIo. Tho IovoI2 nddross fIoId Is In furn nddod fo fhIs nowIy fofchod nddross,
nnd momory Is nccossod ngnIn fo doformIno fho bnso of fho fhIrd ngo fnbIo.

Tho IovoI3 nddross fIoId Is nddod fo fhIs bnso nddross, nnd momory Is rond usIng
fhIs sum fo (fInnIIy) gof fho hysIcnI nddross of fho ngo boIng roforoncod. ThIs nddross
Is concnfonnfod wIfh fho ngo offsof fo gof fho fuII hysIcnI nddross.

Inch ngo fnbIo In fho AIhn nrchIfocfuro Is consfrnInod fo fIf wIfhIn n sIngIo
ngo. Tho fIrsf fhroo IovoIs (0, l, nnd 2) uso hysIcnI nddrossos fhnf nood no furfhor
frnnsInfIon, buf !ovoI 3 Is mnod vIrfunIIy. Thoso normnIIy hIf fho T!I, buf If nof, fho
fnbIo Is nccossod n socond fImo wIfh hysIcnI nddrossos.

Computev AvcLItectuve
TLunguveI Muvugun 236

TLe muppIng oI un AIpLu vIvtuuI uddvess.
Tho AIhn usos n 64-bIf poge IoIle enIr, (PT1) In onch of fhoso ngo fnbIos. Tho fIrsf 32
bIfs confnIn fho hysIcnI ngo frnmo numbor, nnd fho ofhor hnIf IncIudos fho foIIowIng
fIvo rofocfIon fIoIds:
VoliJSnys fhnf fho ngo frnmo numbor Is vnIId for hnrdwnro frnnsInfIon
Ueer reoJ enoIleAIIows usor rogrnms fo rond dnfn wIfhIn fhIs ngo
Kernel reoJ enoIleAIIows fho kornoI fo rond dnfn wIfhIn fhIs ngo
Ueer uriIe enoIleAIIows usor rogrnms fo wrIfo dnfn wIfhIn fhIs ngo
Kernel uriIe enoIleAIIows fho kornoI fo wrIfo dnfn wIfhIn fhIs ngo
Computev AvcLItectuve
TLunguveI Muvugun 23?
In nddIfIon, fho ITI hns fIoIds rosorvod for sysfoms soffwnro fo uso ns If Ionsos.
SInco fho AIhn goos fhrough fhroo IovoIs of fnbIos on n T!I mIss, fhoro nro fhroo
ofonfInI Incos fo chock rofocfIon rosfrIcfIons. Tho AIhn oboys onIy fho boffom-IovoI
ITI, chockIng fho ofhors onIy fo bo suro fho vnIId bIf Is sof.

A Segmented VIvtuuI Memovy umpIe: PvotectIon In tLe InteI PentIum
Tho orIgInnI 8086 usod sogmonfs for nddrossIng, yof If rovIdod nofhIng for
vIrfunI momory or for rofocfIon. Sogmonfs hnd bnso rogIsfors buf no bound rogIsfors
nnd no nccoss chocks, nnd boforo n sogmonf rogIsfor couId bo Iondod fho corrosondIng
sogmonf hnd fo bo In hysIcnI momory. InfoI`s dodIcnfIon fo vIrfunI momory nnd
rofocfIon Is ovIdonf In fho succossors fo fho 8086 (fodny cnIIod IA-32), wIfh n fow fIoIds
oxfondod fo suorf Inrgor nddrossos. ThIs rofocfIon schomo Is oInbornfo, wIfh mnny
dofnIIs cnrofuIIy dosIgnod fo fry fo nvoId socurIfy IoohoIos.
Tho fIrsf onhnncomonf Is fo doubIo fho frndIfIonnI fwo-IovoI rofocfIon modoI:
fho IonfIum hns four IovoIs of rofocfIon. Tho Innormosf IovoI (0) corrosonds fo AIhn
kornoI modo nnd fho ouformosf IovoI (3) corrosonds fo AIhn usor modo. Tho IA-32 hns
sonrnfo sfncks for onch IovoI fo nvoId socurIfy bronchos bofwoon fho IovoIs.
Tho IA-32 dIvIdos fho nddross snco, nI-IowIng bofh fho oornfIng sysfom nnd
fho usor nccoss fo fho fuII snco. Tho IA-32 usor cnn cnII nn oornfIng sysfom roufIno In
fhIs snco nnd ovon nss nrnmofors fo If whIIo rofnInIng fuII rofocfIon. ThIs snfo cnII
Is nof n frIvInI ncfIon, sInco fho sfnck for fho oornfIng sysfom Is dIfforonf from fho
usor`s sfnck. Moroovor, fho IA-32 nIIows fho oornfIng sysfom fo mnInfnIn fho
rofocfIon IovoI of fho colleJ roufIno for fho nrnmofors fhnf nro nssod fo If. ThIs
ofonfInI IoohoIo In rofocfIon Is rovonfod by nof nIIowIng fho usor rocoss fo nsk fho
oornfIng sysfom fo nccoss somofhIng IndIrocfIy fhnf If wouId nof hnvo boon nbIo fo
nccoss IfsoIf. (Such socurIfy IoohoIos nro cnIIod Trojon Ioreee.)

AddIng Bounds CLeckIng und Memovy MuppIng
Tho fIrsf sfo In onhnncIng fho InfoI rocossor wns goffIng fho sogmonfod
nddrossIng fo chock bounds ns woII ns suIy n bnso.
Computev AvcLItectuve
TLunguveI Muvugun 23B
!nfhor fhnn n bnso nddross, ns In fho 8086, sogmonf rogIsfors In fho IA-32
confnIn nn Indox fo n vIrfunI momory dnfn sfrucfuro cnIIod n JeecripIor IoIle.
oscrIfor fnbIos Iny fho roIo of ngo fnbIos In fho AIhn. On fho IA-32 fho oquIvnIonf
of n ngo fnbIo onfry Is n eegnenI JeecripIor. If confnIns fIoIds found In ITIs:
A preoent bitoquIvnIonf fo fho ITI vnIId bIf, usod fo IndIcnfo fhIs Is n vnIId
frnnsInfIon
A buoe fielJoquIvnIonf fo n ngo frnmo nddross, confnInIng fho hysIcnI nddross of
fho frsf byfo of fho sogmonf
An ucceoo bitIIko fho roforonco bIf or uso bIf In somo nrchIfocfuros fhnf Is hoIfuI for
roIncomonf nIgorIfhms
An uttributeo fielJsocIfos fho vnIId oornfIons nnd rofocfIon IovoIs for oornfIons
fhnf uso fhIs sogmonf
Thoro Is nIso n limit fielJ, nof found In ngod sysfoms, whIch osfnbIIshos fho
uor bound of vnIId offsofs for fhIs sogmonf. IIguro 5.4l shows oxnmIos of IA-32
sogmonf doscrIfors.IA-32 rovIdos nn ofIonnI ngIng sysfom In nddIfIon fo fhIs
sogmonfod nddrossIng. Tho uor orfIon of fho 32-bIf nddross soIocfs fho sogmonf
doscrIfor nnd fho mIddIo orfIon Is nn Indox Info fho ngo fnbIo soIocfod by fho
doscrIfor.

AddIng SLuvIng und PvotectIon
To rovIdo for rofocfod shnrIng, hnIf of fho nddross snco Is shnrod by nII
rocossos nnd hnIf Is unIquo fo onch rocoss, cnIIod gloIol oJJreee epoce nnd locol
oJJreee epoce, rosocfIvoIy. Inch hnIf Is gIvon n doscrIfor fnbIo wIfh fho nrorInfo
nnmo.
A doscrIfor oInfIng fo n shnrod sogmonf Is Incod In fho gIobnI doscrIfor fnbIo,
whIIo n doscrIfor for n rIvnfo sogmonf Is Incod In fho IocnI doscrIfor fnbIo.

Computev AvcLItectuve
TLunguveI Muvugun 239

TLe IA-32 segment descvIptovs uve dIstInguIsLed by bIts In tLe uttvIbutes IIeId.
Buoe, limit, preoent, reuJuble, und urituble uve uII seII-epIunutovy.








Computev AvcLItectuve
TLunguveI Muvugun 240
STORAG SYSYMS
4.12 TYPS OI STORAG SYSTMS:
AII sforngo dovIcos nro mngnofIc dIsks, mngnofIc fnos, nufomnfod fno IIbrnrIos,
Cs, nnd Vs.

MugnetIc Isks
MngnofIc dIsks Iny fwo roIos In comufor sysfoms:
!ong-form, nonvoInfIIo sforngo for fIIos, ovon whon no rogrnms nro runnIng
A IovoI of fho momory hIornrchy boIow mnIn momory usod ns n bnckIng sforo for
vIrfunI momory durIng rogrnm oxocufIon.


Isks uve ovgunIzed Into pIuttevs, tvucks, und Sectovs

Computev AvcLItectuve
TLunguveI Muvugun 241
A mngnofIc dIsk consIsfs of n coIIocfIon of pluttero (gonornIIy l fo l2), rofnfIng
on n sIndIo nf 3,600 fo l5,000 rovoIufIons or mInufo (!IM). Thoso Inffors nro mofnI
or gInss dIsks covorod wIfh mngnofIc rocordIng mnforInI on bofh sIdos.
TrndIfIonnIIy, fho bIggosf dIsks hnvo fho hIghosf orformnnco nnd fho smnIIosf
dIsks hnvo fho Iowosf rIco or dIsk drIvo. Tho dIsk surfnco Is dIvIdod Info conconfrIc
cIrcIos, dosIgnnfod trucko. Thoro nro fyIcnIIy 5,000 fo 30,000 frncks on onch surfnco.
Inch frnck In furn Is dIvIdod Info oectoro fhnf confnIn fho InformnfIon; n frnck mIghf
hnvo l00 fo 500 socfors. A socfor Is fho smnIIosf unIf fhnf cnn bo rond or wrIffon.
Tho soquonco rocordod on fho mngnofIc modIn Is n socfor numbor, n gn, fho
InformnfIon for fhnf socfor IncIudIng orror corrocfIon codo, n gn, fho socfor numbor of
fho noxf socfor, nnd so on.
In fho nsf, nII frncks hnd fho snmo numbor of socfors; fho oufor frncks, whIch
nro Iongor, rocordod InformnfIon nf n much Iowor donsIfy fhnn fho Innor frncks.
!ocordIng moro socfors on fho oufor frncks fhnn on fho Innor frncks, cnIIod conotunt
bit Jenoity, Is fho sfnndnrd fodny. ThIs nnmo Is mIsIondIng, ns fho bIf donsIfy Is nof
ronIIy consfnnf.
TyIcnIIy, fho Innor frncks nro rocordod nf fho hIghosf donsIfy nnd fho oufor
frncks nf fho Iowosf, buf fho oufor frncks mIghf rocord, sny, l.? fImos moro bIfs dosIfo
boIng 2.l fImos Iongor.
To rond nnd wrIfo InformnfIon Info n socfor, n movnbIo urm confnInIng n
reuJ/urite heuJ Is Iocnfod ovor onch surfnco. Tho form cylinJer Is usod fo rofor fo nII
fho frncks undor fho nrms nf n gIvon oInf on nII surfncos. To rond or wrIfo n socfor, fho
dIsk confroIIor sonds n commnnd fo movo fho nrm ovor fho roor frnck. ThIs oornfIon
Is cnIIod n eeel, nnd fho fImo fo movo fho nrm fo fho dosIrod frnck Is cnIIod oeek time.
Tho fImo for fho roquosfod socfor fo rofnfo undor fho hond Is fho rotution
lutency ov rotutionul Jeluy. Tho nvorngo Infoncy fo fho dosIrod InformnfIon Is
obvIousIy hnIfwny nround fho dIsk; If n dIsk rofnfos nf l0,000 rovoIufIons or mInufo
(!IM), fho nvorngo rofnfIon fImo Is fhoroforo


Computev AvcLItectuve
TLunguveI Muvugun 242
Tho noxf comononf of dIsk nccoss, trunofer time, Is fho fImo If fnkos fo
frnnsfor n bIock of bIfs, fyIcnIIy n socfor, undor fho rond-wrIfo hond. ThIs fImo Is n
funcfIon of fho bIock sIzo, dIsk sIzo, rofnfIon sood, rocordIng donsIfy of fho frnck, nnd
sood of fho oIocfronIcs connocfIng fho dIsk fo comufor. Iofwoon fho dIsk confroIIor
nnd mnIn momory Is n hIornrchy of confroIIors nnd dnfn nfhs, whoso comIoxIfy vnrIos.

Thoro Is nIso n dosIro fo nmorfIzo fhIs Iong nccoss by rondIng moro fhnn sImIy
whnf Is roquosfod; fhIs Is cnIIod reuJ uheuJ. !ond nhond Is nnofhor cnso of comufor
dosIgns fryIng fo Iovorngo snfInI IocnIIfy fo onhnnco orformnnco.

To hnndIo fho comIoxIfIos of dIsconnocf/connocf nnd rond nhond, fhoro Is
usunIIy, In nddIfIon fo fho dIsk drIvo, n dovIco cnIIod n Jiok controller. Thus, fho fInnI
comononf of dIsk-nccoss fImo Is controller time, whIch Is fho ovorhond fho confroIIor
Imosos In orformIng nn I/O nccoss. Whon roforrIng fo fho orformnnco of n dIsk In n
comufor sysfom, fho fImo sonf wnIfIng for n dIsk fo bocomo froo (queuing Jelo,) Is
nddod fo fhIs fImo.

Mnny dIsks fodny nro shIod In Jiok urruyo. Thoso nrrnys confnIn dozons of
dIsks, nnd mny Iook IIko n sIngIo Inrgo dIsk fo fho comufor. Honco, fhoro Is offon
nnofhor IovoI fo fho sforngo hIornrchy, fho urruy controller.

TLe Iutuve oI MugnetIc Isks
Tho dIsk Indusfry hns conconfrnfod on ImrovIng fho cnncIfy of dIsks.
Imrovomonf In cnncIfy Is cusfomnrIIy oxrossod ns Imrovomonf In oreol JeneiI,,
monsurod In bIfs or squnro Inch:


MngnofIc dIsks hnvo boon chnIIongod mnny fImos for suromncy of socondnry
sforngo. Ono ronson hns boon fho fnbIod ucceoo time gup bofwoon dIsks nnd !AM.
Computev AvcLItectuve
TLunguveI Muvugun 243
Mnny hnvo frIod fo Invonf n fochnoIogy chonor fhnn !AM buf fnsfor fhnn dIsk
fo fIII fhnf gn, buf fhus fnr, nII hnvo fnIIod. So fnr, chnIIongors hnvo novor hnd n
roducf fo mnrkof nf fho rIghf fImo. Iy fho fImo n now roducf wouId shI, !AMs nnd
dIsks hnvo mndo ndvnncos ns rodIcfod onrIIor, cosfs hnvo drood nccordIngIy, nnd fho
chnIIongIng roducf Is ImmodInfoIy obsoIofo.

OptIcuI Isks
Ono chnIIongor fo mngnofIc dIsks Is opIicol conpocI Jiele, or CDe, nnd Ifs
succossor, cnIIod Digitul ViJeo Dioco nnd fhon Digitul Veroutile Dioco or jusf DVDe.
Iofh fho CD-IOM nnd DVD-IOM nro romovnbIo nnd InoxonsIvo fo
mnnufncfuro, buf fhoy nro rond-onIy modIums. Thoso 4.?-Inch dInmofor dIsks hoId 0.65
nnd 4.? CI, rosocfIvoIy, nIfhough somo Vs wrIfo on bofh sIdos fo doubIo fhoIr
cnncIfy. ThoIr hIgh cnncIfy nnd Iow cosf hnvo Iod fo C-!OMs nnd V!OMs
roIncIng fIoy dIsks ns fho fnvorIfo modIum for dIsfrIbufIng soffwnro nnd ofhor fyos
of comufor dnfn.
Tho ouInrIfy of Cs nnd musIc fhnf cnn bo downIondod from fho WWW Iod fo n
mnrkof for rowrIfnbIo Cs, convonIonfIy cnIIod C-!W, nnd wrIfo onco Cs, cnIIod C-
R. C-!Ws nnd C-!s rond nf nbouf hnIf fho sood of C-!OMs nnd C!Ws nnd C-
!s wrIfo nf nbouf n qunrfor fho sood of C-!OMs.
Thoy nro nIso wrIfo-onco nnd rowrIfnbIo Vs, cnIIod V-! nnd (nIns)
V!AM. !owrIfnbIo V drIvos cosf fon fImos ns much ns V-!OM drIvos. V-
!AM ronds nnd wrIfos nf nbouf n fhIrd of fho sood of V-!OMs, nnd V-! wrIfos
nf fho sood of V-!AM nnd ronds nf fho sood of V-!OMs.

MugnetIc Tupes
MngnofIc fnos hnvo boon nrf of comufor sysfoms ns Iong ns dIsks bocnuso
fhoy uso fho sImIInr fochnoIogy ns dIsks. Tho Inhoronf cosf/orformnnco dIfforonco
bofwoon dIsks nnd fnos Is bnsod on fhoIr goomofrIos:
IIxod rofnfIng Inffors offor rnndom nccoss In mIIIIsoconds, buf dIsks hnvo n
IImIfod sforngo nron nnd fho sforngo modIum Is sonIod wIfhIn onch rondor.
Computev AvcLItectuve
TLunguveI Muvugun 244
!ong sfrIs wound on romovnbIo sooIs of unIImIfod Iongfh monn mnny fnos
cnn bo usod or rondor, buf fnos roquIro soquonfInI nccoss fhnf cnn fnko
soconds.

Ono of fho IImIts of fnos hnd boon fho sood nf whIch fho fnos cnn sIn
wIfhouf bronkIng or jnmmIng. A fochnoIogy cnIIod helicul ocun tupeo soIvos fhIs
robIom by kooIng fho fno sood fho snmo buf rocordIng fho InformnfIon on n
dIngonnI fo fho fno wIfh n fno rondor fhnf sIns much fnsfor fhnn fho fno Is movIng.
ThIs fochnoIogy Incronsos rocordIng donsIfy by nbouf n fncfor of 20 fo 50. HoIIcnI
scnn fnos woro dovoIood for Iow-cosf VC!s nnd cnmcordors, whIch broughf down fho
cosf of fho fnos nnd rondors.
Ono dvuwbuck fo fnos Is fhnf fhoy wonr ouf; fho hoIIcnI scnn rond/wrIfo honds
nIso wonr ouf quIckIy. IInnIIy, fhoro nro fyIcnIIy Iong rowInd, ojocf, Iond, nnd sIn-u
fImos for hoIIcnI scnn fnos.
In nddIfIon fo fho Issuo of cnncIfy, nnofhor chnIIongo Is rocovory fImo. Tnos nro
nIso nof kooIng u In bnndwIdfh of dIsks. Thus, ns dIsks confInuo fo grow, Ifs Is nof
onIy moro oxonsIvo fo uso fnos for bnckus, If wIII nIso fnko much Iongor fo rocovor If
n dIsnsfor occurs. ThIs growIng gn bofwoon rnfo of Imrovomonf In dIsks nnd fnos
cnIIs Info quosfIon fho sonsIbIIIfy of fno bncku for dIsk sforngo.

Automuted Tupe IIbvuvIes
Tno cnncIfIos nro onhnncod by InoxonsIvo robofs fo nufomnfIcnIIy Iond nnd
sforo fnos, offorIng n now IovoI of sforngo hIornrchy. Thoso neurline fnos monn
nccoss fo fornbyfos of InformnfIon In fons of soconds, wIfhouf fho InforvonfIon of n
humnn oornfor.
Thoro nro mnny vorsIons of fno IIbrnrIos, buf fhoso mochnnIcnI mnrvoIs nro nof
ns roIInbIo ns ofhor nrfs of fho comufor; If`s nof uncommon for fno IIbrnrIos fo hnvo
fnIIuro rnfos n fncfor of l0 hIghor fhnn ofhor sforngo dovIcos.



Computev AvcLItectuve
TLunguveI Muvugun 245
IIusL Memovy
Imboddod dovIcos nIso nood nonvoInfIIo sforngo, buf romIums Incod on snco
nnd owor normnIIy Iond fo fho uso of IInsh momory Insfond of mngnofIc rocordIng.
IInsh momory Is nIso usod ns n rowrIfnbIo !OM In omboddod sysfom, fyIcnIIy fo nIIow
soffwnro fo bo ugrndod wIfhouf hnvIng fo roInco chIs. AIIcnfIons nro fyIcnIIy
rohIbIfod from wrIfIng fo fInsh momory In such cIrcumsfnncos.
!Iko oIocfrIcnIIy ornsnbIo nnd rogrnmmnbIo rond-onIy momorIos (III!OM),
IInsh momory Is wrIffon by InducIng fho funnoIIng of chnrgo from frnnsIsfor gnIn fo n
fIonfIng gnfo.
Comnrod fo dIsks, IInsh momorIos offor Iow owor consumfIon (Ioss fhnn 50
mIII wnffs), cnn bo soId In smnII sIzos, nnd offor rond nccoss fImos comnrnbIo fo
!AMs.
A bIock of IInsh momory nro fIrsf oIocfrIcnIIy ornsod, nnd fhon wrIffon wIfh 0s
nnd ls. If fho IogIcnI dnfn Is smnIIor fhnn fho IInsh bIock sIzo, fho good dnfn fhnf
shouId survIvo musf bo coIod fo nnofhor bIock boforo fho oId bIock cnn bo ornsod. Thus,
InformnfIon Is orgnnIzod In IInsh ns IInkod IIsfs of bIocks.

4.13 BUSSCONNCTING I/O VICS TO CPU/MMORY
Tho bus sorvos ns n shnrod communIcnfIon IInk bofwoon fho subsysfoms. Tho
fwo mnjor ndvnnfngos of fho bus orgnnIznfIon nro Iow cosf nnd vorsnfIIIfy. Tho mnjor
dIsndvnnfngo of n bus Is fhnf If cronfos n communIcnfIon boffIonock, ossIbIy IImIfIng
fho mnxImum I/O fhroughuf. Whon I/O musf nss fhrough n confrnI bus, fhIs
bnndwIdfh IImIfnfIon Is ns ronI nsnnd somofImos moro sovoro fhnnmomory
bnndwIdfh. In sorvor sysfoms, whoro I/O Is froquonf, dosIgnIng n bus sysfom cnnbIo of
moofIng fho domnnds of fho rocossor Is n mnjor chnIIongo.
Iusos woro frndIfIonnIIy cInssIfIod ns CPU-memory buoeo ov 1/O buoeo. I/O
busos mny bo Iongfhy, mny hnvo mnny fyos of dovIcos connocfod fo fhom, hnvo n wIdo
rnngo In fho dnfn bnndwIdfh of fho dovIcos connocfod fo fhom, nnd normnIIy foIIow n
bus sfnndnrd. CI!-momory busos, on fho ofhor hnnd, nro shorf, gonornIIy hIgh sood,
nnd mnfchod fo fho momory sysfom fo mnxImIzo momory-CI! bnndwIdfh.
Computev AvcLItectuve
TLunguveI Muvugun 246
urIng fho dosIgn hnso, fho dosIgnor of n CI!-momory bus knows nII fho fyos
of dovIcos fhnf musf connocf fogofhor, whIIo fho I/O bus dosIgnor musf nccof dovIcos
vnryIng In Infoncy nnd bnndwIdfh cnnbIIIfIos. To Iowor cosfs, somo comufors hnvo n
sIngIo bus for bofh momory nnd I/O dovIcos. In fho quosf for hIghor I/O orformnnco,
somo busos nro n hybrId of fho fwo. Ior oxnmIo, ICI Is roInfIvoIy shorf, nnd Is usod fo
connocf fo moro frndIfIonnI I/O busos vIn brIdgos fhnf sonk bofh ICI on ono ond nnd
fho I/O bus rofocoI on fho ofhor. To IndIcnfo Ifs InformodInfo sfnfo, such busos nro
somofImos cnIIod mexxunine.
A bus frnnsncfIon IncIudos fwo nrfs: sondIng fho nddross nnd rocoIvIng or
sondIng fho dnfn. Ius frnnsncfIons nro usunIIy dofInod by whnf fhoy do fo momory: A
reoJ frnnsncfIon frnnsfors dnfn fron momory (fo oIfhor fho CI! or nn I/O dovIco), nnd
n uriIe frnnsncfIon wrIfos dnfn fo fho momory.


TypIcuI bus veud tvunsuctIon.

Computev AvcLItectuve
TLunguveI Muvugun 24?
Bus esIgn ecIsIons
Tho dosIgn of n bus rosonfs sovornI ofIons, ns IIguro ?.8 shows. !Iko fho rosf
of fho comufor sysfom, docIsIons doond on cosf nnd orformnnco gonIs. Tho fIrsf fhroo
ofIons In fho fIguro nro cIonrsonrnfo nddross nnd dnfn IInos, wIdor dnfn IInos, nnd
muIfIIo-word frnnsfors nII gIvo hIghor orformnnco nf moro cosf.
Tho noxf Ifom In fho fnbIo concorns fho numbor of buo muotero. Thoso dovIcos
cnn InIfInfo n rond or wrIfo frnnsncfIon; fho CI!, for Insfnnco, Is nIwnys n bus mnsfor.
A bus hns muIfIIo mnsfors whon fhoro nro muIfIIo CI!s or whon I/O dovIcos cnn
InIfInfo n bus frnnsncfIon.
WIfh muIfIIo mnsfors, n bus cnn offor hIghor bnndwIdfh by usIng nckofs, ns
oosod fo hoIdIng fho bus for fho fuII frnnsncfIon. ThIs fochnIquo Is cnIIod oplit
trunouctiono.
Somo sysfoms cnII fhIs nbIIIfy connect/Jioconnect, u pipelineJ buo, u penJeJ
buo, ov u pucket-ouitcheJ buo; fho noxf chnfor goos Info moro dofnII on nckof
swIfchIng.

OptIon HIgL pevIovmunce Iow cost
Ius wIdfh Sonrnfo nddross nnd dnfn IInos
MuIfIIox nddross nnd dnfn
IInos
nfn wIdfh WIdor Is fnsfor (o.g., 64 bIfs)
nrrowor Is chonor (o.g., 8
bIfs)
Trnnsfor sIzo
MuIfIIo words hnvo Ioss bus
ovorhond
SIngIo-word frnnsfor Is sImIor
Ius mnsfors MuIfIIo (roquIros nrbIfrnfIon) SIngIo mnsfor (no nrbIfrnfIon)
SIIf
frnnsncfIon`
Yossonrnfo roquosf nnd
roIy nckofs gof hIghor
bnndwIdfh (nood muIfIIo
mnsfors)
oconfInuous connocfIon Is
chonor nnd hns Iowor Infoncy
CIockIng Synchronous Asynchronous

Computev AvcLItectuve
TLunguveI Muvugun 24B
Tho fInnI Ifom clocking, concorns whofhor n bus Is synchronous or
nsynchronous. If n bus Is oynchronouo, If IncIudos n cIock In fho confroI IInos nnd n
fIxod rofocoI for sondIng nddross nnd dnfn roInfIvo fo fho cIock. SInco IIffIo or no IogIc
Is noodod fo docIdo whnf fo do noxf, fhoso busos cnn bo bofh fnsf nnd InoxonsIvo. An
uoynchronouo bus, on fho ofhor hnnd, Is nof cIockod. Insfond, soIf-fImod, hnndshnkIng
rofocoIs nro usod bofwoon bus sondor nnd rocoIvor.

A spIIt-tvunsuctIon bus.

Bus Stunduvds
Sfnndnrds fhnf Iof fho comufor dosIgnor nnd I/O-dovIco dosIgnor work
IndoondonfIy Iny n Inrgo roIo In busos. As Iong ns bofh dosIgnors moof fho
roquIromonfs, nny I/O dovIco cnn connocf fo nny comufor. Tho I/O bus sfnndnrd Is fho
documonf fhnf dofInos how fo connocf dovIcos fo comufors.
Tho Cood
!of fho comufor nnd I/O-dovIco dosIgnors work IndoondonfIy
IrovIdos n nfh for socond nrfy (o.g. chonor) comofIfIon
Computev AvcLItectuve
TLunguveI Muvugun 249
Tho Ind
Iocomo mnjor orformnnco nnchors
InhIbIf chnngo
How fo cronfo n sfnndnrd
Ioffom-u
Comnny frIos fo gof sfnndnrds commIffoo fo nrovo If`s Infosf
hIIosohy In hoos fhnf fhoy`II gof fho jum on fho ofhors (o.g. S
bus, IC-AT bus, ...)
o fncfo sfnndnrds
To-down
osIgn by commIffoo (ICI, SCSI, ...)
Somo snmIo bus dosIgns nro shown boIow

IntevIucIng Stovuge evIces to tLe CPU
Tho I/O bus Is connocfod fo fho mnIn momory bus Is shown In fIguro.Irocossor
Inforfnco wIfh I/o bus cnn bo dono wIfh fwo fochnIquos ono usIng Inforrufs nnd socond
usIng momory mnod I/O.
I/O ConfroI Sfrucfuros
IoIIIng
Inforrufs
MA
I/O ConfroIIors
I/O Irocossors
Computev AvcLItectuve
TLunguveI Muvugun 250
Tho sImIo Inforfnco, In whIch fho CI! orIodIcnIIy chocks sfnfus bIfs fo soo If If
Is fImo for fho noxf I/O oornfIon, Is cnIIod polling.


A typIcuI IntevIuce oI I/O devIces und un I/O bus to tLe CPU-memovy bus.

Computev AvcLItectuve
TLunguveI Muvugun 251
1nterrupt-Jriten I/O, usod by mosf sysfoms for nf Ionsf somo dovIcos, nIIows
fho CI! fo work on somo ofhor rocoss whIIo wnIfIng for fho I/O dovIco.
Ior oxnmIo, fho !Ill hns n modo fhnf nIIows If fo Inforruf fho CI! whonovor
fho dono bIf or orror bIf Is sof. In gonornI-uroso nIIcnfIons, Inforruf-drIvon I/O Is
fho koy fo muIfIfnskIng oornfIng sysfoms nnd good rosonso fImos.
Tho dvuwbuck to Intevvupts Is fho oornfIng sysfom ovorhond on onch ovonf.
In ronI-fImo nIIcnfIons wIfh hundrods of I/O ovonfs or socond, fhIs ovorhond cnn bo
InfoIornbIo. Ono hybrId soIufIon for ronI-fImo sysfoms Is fo uso n cIock fo orIodIcnIIy
Inforruf fho CI!, nf whIch fImo fho CI! oIIs nII I/O dovIcos
Tho MA hnrdwnro Is n socInIIzod rocossor fhnf frnnsfors dnfn bofwoon
momory nnd nn I/O dovIco whIIo fho CI! goos on wIfh ofhor fnsks. Thus, If Is oxfornnI
fo fho CI! nnd musf ncf ns n mnsfor on fho bus. Tho CI! frsf sofs u fho MA
rogIsfors, whIch confnIn n momory nddross nnd numbor of byfos fo bo frnnsforrod. Moro
sohIsfIcnfod MA dovIcos suorf ocutter/guther, whoroby n MA dovIco cnn wrIfo
or rond dnfn from n IIsf of sonrnfo nddrossos. Onco fho MA frnnsfor Is comIofo, fho
MA confroIIor Inforrufs fho CI!. Thoro mny bo muIfIIo MA dovIcos In n comufor
sysfom.
eIegutIng I/O ResponsIbIIIty Ivom tLe CPU
Inforruf-drIvon I/O roIIovos fho CI! from wnIfIng for ovory I/O ovonf, buf
mnny CI! cycIos nro sfIII sonf In frnnsforrIng dnfn. TrnnsforrIng n dIsk bIock of 2048
words, for Insfnnco, wouId roquIro nf Ionsf 2048 Ionds from dIsk fo CI! rogIsfors nnd
2048 sforos from CI! rogIsfors fo momory, ns woII ns fho ovorhond for fho Inforruf.
SInco I/O ovonfs so offon InvoIvo bIock frnnsfors, Jirect memory ucceoo (MA)
hnrdwnro Is nddod fo mnny comufor sysfoms fo nIIow frnnsfors of numbors of words
wIfhouf InforvonfIon by fho CI!.
Moro sohIsfIcnfod MA dovIcos suorf ocutter/guther, whoroby n MA
dovIco cnn wrIfo or rond dnfn from n IIsf of sonrnfo nddrossos. Onco fho MA frnnsfor
Is comIofo, fho MA confroIIor Inforrufs fho CI!.
Thoro mny bo muIfIIo MA dovIcos In n comufor sysfom; for oxnmIo, MA Is
froquonfIy nrf of fho confroIIor for nn I/O dovIco.
Computev AvcLItectuve
TLunguveI Muvugun 252

ovIcos cnIIod 1/O proceoooro (ov chunnel controllero) oornfo oIfhor from
fIxod rogrnms or from rogrnms downIondod by fho oornfIng sysfom. Tho oornfIng
sysfom fyIcnIIy sofs u n quouo of 1/O control blocko fhnf confnIn InformnfIon such
ns dnfn IocnfIon (sourco nnd dosfInnfIon) nnd dnfn sIzo.
I/O rocossors nro sImIInr fo muIfIrocossors In fhnf fhoy fncIIIfnfo sovornI
rocossos boIng oxocufod sImuIfnnoousIy In fho comufor sysfom. I/O rocossors nro
Ioss gonornI fhnn CI!s, howovor, sInco fhoy hnvo dodIcnfod fnsks, nnd fhus fho
nrnIIoIIsm fhoy onnbIo Is much moro IImIfod. In nddIfIon, nn I/O rocossor doosn`f
normnIIy chnngo InformnfIon, ns n CI! doos, buf jusf movos InformnfIon from ono
Inco fo nnofhor.

4.14 RIIABIIITY, AVAIIABIIITY, AN PNABIIITY

eIInIng IuIIuve
Comufor sysfom JepenJubility Is fho qunIIfy of doIIvorod sorvIco such fhnf
roIInnco cnn jusfIfInbIy bo Incod on fhIs sorvIco. Tho oertice doIIvorod by n sysfom Is
Ifs obsorvod uctuul behutior ns orcoIvod by ofhor sysfom(s) InforncfIng wIfh fhIs
sysfom`s usors. Inch moduIo nIso hns nn IdonI opecifieJ behutior, whoro n eertice
opecificution Is nn ngrood doscrIfIon of fho oxocfod bohnvIor.
A sysfom foilure occurs whon fho ncfunI bohnvIor dovInfos from fho socIfIod
bohnvIor. Tho fnIIuro occurrod bocnuso nn error, n dofocf In fhnf moduIo. Tho cnuso of
nn orror Is n foulI.
Whon n fnuIf occurs If cronfos n lutent error, whIch bocomos effecIite whon If Is
ncfIvnfod; whon fho orror ncfunIIy nffocfs fho doIIvorod sorvIco, n fnIIuro occurs. Tho
fImo bofwoon fho occurronco of nn orror nnd fho rosuIfIng fnIIuro Is fho error lutency.
Thus, nn orror Is fho mnnIfosfnfIon in IIe e,eIen of n fnuIf, nnd n fnIIuro Is fho
mnnIfosfnfIon on IIe eertice of nn orror.



Computev AvcLItectuve
TLunguveI Muvugun 253
Tho roInfIon bofwoon fnuIfs, orrors, nnd fnIIuros Is:
A fnuIf cronfos ono or moro Infonf orrors.
Tho roorfIos of orrors nro
n) n Infonf orror bocomos offocfIvo onco ncfIvnfod;
b) nn orror mny cycIo bofwoon Ifs Infonf nnd offocfIvo sfnfos;
c) nn offocfIvo orror offon rongnfos from ono comononf fo nnofhor,
fhoroby cronfIng now orrors.
Thus, nn offocfIvo orror Is oIfhor n formorIy Infonf orror In fhnf comononf
or If hns rongnfod from nnofhor orror In fhnf comononf or from
oIsowhoro.
A comononf fnIIuro occurs whon fho orror nffocfs fho doIIvorod sorvIco.
Thoso roorfIos nro rocursIvo, nnd nIy fo nny comononf In fho sysfom.

!sors orcoIvo n sysfom nIfornnfIng bofwoon fwo sfnfos of doIIvorod sorvIco wIfh
rosocf fo fho sorvIco socIfIcnfIon:
l. Sertice uccompliohment, whoro fho sorvIco Is doIIvorod ns socIfIod,
2. Sertice interruption, whoro fho doIIvorod sorvIco Is dIfforonf from fho socIfIod
sorvIco.
TrnnsIfIons bofwoon fhoso fwo sfnfos nro cnusod by fnIIuros (from sfnfo l fo sfnfo 2) or
reeIoroIione (2 fo l). QunnfIfyIng fhoso frnnsIfIons Iond fo fho fwo mnIn monsuros of
doondnbIIIfy:
l. MoJule reliubility Is n monsuro of fho confInuous sorvIco nccomIIshmonf (or,
oquIvnIonfIy, of fho fImo fo fnIIuro) from n roforonco InIfInI Insfnnf. Tho
rocIrocnI of MTTI Is n rnfo of fnIIuros. If n coIIocfIon of moduIos hnvo
oxononfInIIy dIsfrIbufod IIfofImos, fho ovornII fnIIuro rnfo of fho coIIocfIon Is fho
sum of fho fnIIuro rnfos of fho moduIos. SorvIco InforrufIon Is monsurod ns
Monn TImo To !onIr (MTT!).
2. MoJule utuilubility Is n monsuro of fho sorvIco nccomIIshmonf wIfh rosocf fo
fho nIfornnfIon bofwoon fho fwo sfnfos of nccomIIshmonf nnd InforrufIon. Ior
non-rodundnnf sysfoms wIfh ronIr, moduIo nvnIInbIIIfy Is sfnfIsfIcnIIy
qunnfIfIod ns:
Computev AvcLItectuve
TLunguveI Muvugun 254

Meon Tine BeIueen Ioiluree (MTBI) Is sImIy fho sum of MTTI + MTT!.
CInssIfy fnuIfs Info four cnfogorIos nccordIng fo fhoIr cnuso:
l. HurJuure fuulto: dovIcos fhnf fnII.
2. Deoign fuulto: fnuIfs In soffwnro (usunIIy) nnd hnrdwnro dosIgn (occnsIonnIIy).
3. Operution fuulto: mIsfnkos by oornfIons nnd mnInfonnnco orsonnoI.
4. Entironmentul fuulto: fIro, fIood, onrfhqunko, owor fnIIuro, nnd snbofngo.

InuIfs nro nIso cInssIfIod by fhoIr durnfIon Info frnnsIonf, InformIffonf, nnd ormnnonf.
Trunoient fuulto oxIsf for n IImIfod fImo nnd nro nof rocurrIng.
1ntermittent fuulto cnuso n sysfom fo oscIIInfo bofwoon fnuIfy nnd fnuIf froo
oornfIon.
Permunent fuulto do nof corrocf fhomsoIvos wIfh nssIng of fImo.
IvIdo Imrovomonfs In moduIo roIInbIIIfy Info toliJ coneIrucIion nnd error
correcIion. Lutent error proceooing doscrIbos fho rncfIco of fryIng fo dofocf nnd
ronIr orrors boforo fhoy bocomo offocfIvo, such ns rovonfnfIvo mnInfonnnco. 1ffecIite
error proceeeing doscrIbos corrocfIon of fho orror nffor If bocomos offocfIvo, oIfhor by
noeling fho orror or by recotering from fho orror. Irror corrocfIon, such ns fhnf usod In
dIsk socfors, cnn mnsk orrors. Irror rocovory Is oIfhor IocluorJrofurnIng fo n
rovIous corrocf sfnfo, such ns wIfh chockoInf-rosfnrfor foruorJconsfrucfIng n now
corrocf sfnfo, such ns by rosondIng n dIsk bIock.
TnkIng n sIIghfIy dIfforonf vIow, !nrIo dIvIdos roIInbIIIfy Imrovomonfs Info four
mofhods:
l. Fuult utoiJunce: how fo rovonf, by coneIrucIion, fnuIf occurronco;
2. Fuult tolerunce: how fo rovIdo, by reJunJonc,, sorvIco comIyIng wIfh fho sorvIco
socIfIcnfIon In sIfo of fnuIfs hnvIng occurrod or nro occurrIng;
3. Error remotul: how fo mInImIzo, by terificoIion, fho rosonco of Infonf orrors;
4. Error forecuoting: how fo osfImnfo, by etoluoIion, fho rosonco, cronfIon, nnd
consoquoncos of orrors.

Computev AvcLItectuve
TLunguveI Muvugun 255
4.15 RAI: RUNANT ARRAYS OI INXPNSIV ISKS

An InnovnfIon fhnf Imrovos bofh doondnbIIIfy nnd orformnnco of sforngo
sysfoms Is Jiel orro,e. Ono nrgumonf for nrrnys Is fhnf ofonfInI fhroughuf cnn bo
Incronsod by hnvIng mnny dIsk drIvos nnd, honco, mnny dIsk nrms, rnfhor fhnn ono
Inrgo drIvo wIfh ono dIsk nrm.
AIfhough n dIsk nrrny wouId hnvo moro fnuIfs fhnn n smnIIor numbor of Inrgor
dIsks whon onch dIsk hns fho snmo roIInbIIIfy, doondnbIIIfy cnn bo Imrovod by nddIng
rodundnnf dIsks fo fho nrrny fo foIornfo fnuIfs. Thnf Is, If n sIngIo dIsk fnIIs, fho Iosf
InformnfIon cnn bo roconsfrucfod from rodundnnf InformnfIon.
Tho onIy dnngor Is In hnvIng nnofhor dIsk fnII bofwoon fho fImo fho frsf dIsk
fnIIs nnd fho fImo If Is roIncod (formod neon Iine Io repoir, or MTT!). SInco fho neon
Iine Io foilure (MTTI) of dIsks Is fons of yonrs, nnd fho MTT! Is monsurod In hours,
rodundnncy cnn mnko fho monsurod roIInbIIIfy of l00 dIsks much hIghor fhnn fhnf of n
sIngIo dIsk.
Thoso sysfoms hnvo bocomo known by fho ncronym IA1D, sfnnd-Ing orIgInnIIy
for reJunJonI orro, of inexpeneite Jiele, nIfhough somo hnvo ro-nnmod If fo reJunJonI
orro, of inJepenJenI Jiele
Tho sovornI nronchos fo rodundnncy hnvo dIfforonf ovorhond nnd orfor-
mnnco. IIguro shows fho sfnndnrd !AI IovoIs. If shows how oIghf dIsks of usor dnfn
musf bo suIomonfod by rodundnnf or chock dIsks nf onch !AI IovoI. If nIso shows
fho mInImum numbor of dIsk fnIIuros fhnf n sysfom wouId survIvo.
No Redunduncy (RAI 0)
ThIs nofnfIon Is rofors fo n dIsk nrrny In whIch dnfn Is sfrIod buf fhoro Is no
rodundnncy fo foIornfo dIsk fnIIuro.
SfrIIng ncross n sof of dIsks mnkos fho coIIocfIon nonr fo soffwnro ns n sIngIo
Inrgo dIsk, whIch sImIIfos sforngo mnnngomonf. If nIso Imrovos orformnnco for
Inrgo nccossos, sInco mnny dIsks cnn oornfo nf onco. VIdoo odIfIng sysfoms, for
oxnmIo, offon sfrIo fhoIr dnfn.

Computev AvcLItectuve
TLunguveI Muvugun 256
RAI IeveIs, tLeIv IuuIt toIevunce, und tLeIv ovevLeud In vedundunt dIsks.
RAI IeveI MInImum
numbev
oI Isk
IuuIts
suvvIved
umpIe
utu
dIsks
CovvespondIng
CLeck dIsks
CovpovutIons
pvoducIng RAI
pvoducts ut tLIs
IeveI
0 on-
rodundnnf
sfrIod
0 8 0 WIdoIy usod
l MIrrorod l 8 8
IMC, Comnq
(Tnndom), IIM
2 Momory-
sfyIo ICC
l 8 4

3 IIf-
InforIonvod
nrIfy
l 8 l Sforngo Concofs
4 IIock-
InforIonvod
nrIfy
l 8 l
ofwork
AIInnco
5 IIock-
InforIonvod
dIsfrIbufod
nrIfy
l 8 l WIdoIy usod
6 I+Q
rodundnncy
2 8 2

!AI 0 somofhIng of n mIsnomor ns fhoro Is no rodundnncy, If Is nof In fho
orIgInnI !AI fnxonomy, nnd sfrIIng rodnfos !AI. Howovor, !AI IovoIs nro offon
Ioff fo fho oornfor fo sof whon cronfIng n sforngo sysfom, nnd !AI 0 Is offon IIsfod ns
ono of fho ofIons. Honco, fho form !AI 0 hns bocomo wIdoIy usod.
Computev AvcLItectuve
TLunguveI Muvugun 25?

MIvvovIng (RAI 1)
ThIs frndIfIonnI schomo for foIornfIng dIsk fnIIuro, cnIIod nirroring or
eIoJouing, usos fwIco ns mnny dIsks ns doos !AI 0. Whonovor dnfn Is wrIffon fo ono
dIsk, fhnf dnfn Is nIso wrIffon fo n rodundnnf dIsk, so fhnf fhoro nro nIwnys fwo coIos
of fho InformnfIon. If n dIsk fnIIs, fho sysfom jusf goos fo fho mIrror fo gof fho dosIrod
InformnfIon.

MIrrorIng Is fho mosf oxonsIvo !AI soIufIon, sInco If roquIros fho mosf
dIsks.Tho !AI formInoIogy hns ovoIvod fo cnII fho formor !AI l+0 or !AI l0
(sfrIod mIrrors) nnd fho Inffor !AI 0+l or !AI 0l (mIrrorod sfrIos).

BIt-IntevIeuved PuvIty (RAI 3)
Tho cosf of hIghor nvnIInbIIIfy cnn bo roducod fo l/A, whoro A Is fho numbor of
dIsks In n proIecIion group. !nfhor fhnn hnvo n comIofo coy of fho orIgInnI dnfn for
onch dIsk, wo nood onIy ndd onough rodundnnf InformnfIon fo rosforo fho Iosf
InformnfIon on n fnIIuro. !onds or wrIfos go fo nII dIsks In fho grou, wIfh ono oxfrn
dIsk fo hoId fho chock InformnfIon In cnso fhoro Is n fnIIuro. !AI 3 Is ouInr In
nIIcnfIons wIfh Inrgo dnfn sofs, such ns muIfImodIn nnd somo scIonfIfIc codos.

PoriI, Is ono such schomo. !ondors unfnmIIInr wIfh nrIfy cnn fhInk of fho
rodundnnf dIsk ns hnvIng fho sum of nII fho dnfn In fho ofhor dIsks. Whon n dIsk fnIIs,
fhon you subfrncf nII fho dnfn In fho good dIsks from fho nrIfy dIsk; fho romnInIng
InformnfIon musf bo fho mIssIng InformnfIon. InrIfy Is sImIy fho sum moduIo fwo. Tho
nssumfIon bohInd fhIs fochnIquo Is fhnf fnIIuros nro so rnro fhnf fnkIng Iongor fo
rocovor from fnIIuro buf roducIng rodundnnf sforngo Is n good frndo-off.


Computev AvcLItectuve
TLunguveI Muvugun 25B
BIock-IntevIeuved PuvIty und IstvIbuted BIock-IntevIeuved PuvIty (RAI 4
und RAI 5)
In !AI 3, ovory nccoss wonf fo nII dIsks. Somo nIIcnfIons wouId rofor fo do
smnIIor nccossos, nIIowIng Indoondonf nccossos fo occur In nrnIIoI. Thnf Is fho
uroso of fho noxf !AI IovoIs.
SInco orror-dofocfIon InformnfIon In onch socfor Is chockod on ronds fo soo If dnfn
Is corrocf, such smnII ronds fo onch dIsk cnn occur IndoondonfIy ns Iong ns fho
mInImum nccoss Is ono socfor. WrIfos nro nnofhor mnffor. If wouId soom fhnf onch
smnII wrIfo wouId domnnd fhnf nII ofhor dIsks bo nccossod fo rond fho rosf of fho
InformnfIon noodod fo rocnIcuInfo fho now nrIfy, ns In IIguro.
A smnII wrIfo wouId roquIro rondIng fho oId dnfn nnd oId nrIfy, nddIng fho
now InformnfIon, nnd fhon wrIfIng fho now nrIfy fo fho nrIfy dIsk nnd fho now dnfn
fo fho dnfn dIsk. !AI 4 offcIonfIy suorfs n mIxfuro of Inrgo ronds, Inrgo wrIfos,
smnII ronds, nnd smnII wrIfos. Ono drnwbnck fo fho sysfom Is fhnf fho nrIfy dIsk musf
bo udnfod on ovory wrIfo, so If Is fho boffIonock for bnck-fo-bnck wrIfos. To fIx fho
nrIfy-wrIfo boffIonock, fho nrIfy InformnfIon cnn bo srond fhroughouf nII fho dIsks
so fhnf fhoro Is no sIngIo boffIonock for wrIfos. Tho dIsfrIbufod nrIfy orgnnIznfIon Is
!AI 5.
IIguro shows how dnfn nro dIsfrIbufod In !AI 4 vs. !AI 5. As fho
orgnnIznfIon on fho rIghf shows, In !AI 5 fho nrIfy nssocInfod wIfh onch row of dnfn
bIocks Is no Iongor rosfrIcfod fo n sIngIo dIsk.
ThIs orgnnIznfIon nIIows muIfIIo wrIfos fo occur sImuIfnnoousIy ns Iong ns fho
sfrIo unIfs nro nof Iocnfod In fho snmo dIsks. Ior oxnmIo, n wrIfo fo bIock 8 on fho
rIghf musf nIso nccoss Ifs nrIfy bIock I2, fhoroby occuyIng fho frsf nnd fhIrd dIsks. A
socond wrIfo fo bIock 5 on fho rIghf, ImIyIng nn udnfo fo Ifs nrIfy bIock Il, nccossos
fho socond nnd fourfh dIsks nnd fhus couId occur nf fho snmo fImo ns fho wrIfo fo bIock
8. Thoso snmo wrIfos fo fho orgnnIznfIon on fho Ioff wouId rosuIf In chnngos fo bIocks
Il nnd I2, bofh on fho fIffh dIsk, whIch wouId bo n boffIonock.

Computev AvcLItectuve
TLunguveI Muvugun 259






Computev AvcLItectuve
TLunguveI Muvugun 260

P+Q vedunduncy (RAI 6)
InrIfy bnsod schomos rofocf ngnInsf n sIngIo, soIf-IdonfIfyIng fnIIuros. Whon n
sIngIo fnIIuro Is nof suffIcIonf, nrIfy cnn bo gonornIIzod fo hnvo n socond cnIcuInfIon
ovor fho dnfn nnd nnofhor chock dIsk of InformnfIon. Yof nnofhor nrIfy bIock Is nddod
fo nIIow rocovory from n socond fnIIuro. Thus, fho sforngo ovorhond Is fwIco fhnf of
!AI 5. Tho smnII wrIfo shorfcuf of IIguro works ns woII, ox-cof now fhoro nro sIx
dIsk nccossos Insfond of four fo udnfo bofh I nnd Q InformnfIon.
4.16 RRORS AN IAIIURS IN RAI SYSTMS
IubIIcnfIons of ronI orror rnfos nro rnro for fwo ronsons. IIrsf ncndomIcs rnroIy
hnvo nccoss fo sIgnIfIcnnf hnrdwnro rosourcos fo monsuro. Socond IndusfrInI,
rosonrchors nro rnroIy nIIowod fo ubIIsh fnIIuro InformnfIon for fonr fhnf If wouId bo
usod ngnInsf fhoIr comnnIos In fho mnrkofInco. IoIow nro four oxcofIons.
BevkeIey's TevtIuvy Isk
Tho TorfInry Isk rojocf nf fho !nIvorsIfy of CnIIfornIn cronfod nn nrf-Imngo
sorvor for fho IIno Arfs Musoums of Snn IrnncIsco. ThIs dnfnbnso consIsfs of hIgh
qunIIfy Imngos of ovor ?0,000 nrf works. Tho dnfnbnso wns sforod on n cIus-for, whIch
consIsfod of 20 ICs confnInIng 368 dIsks connocfod by n swIfchod Ifhornof. If occuIod
In sovon ?-foof hIgh rncks. IIguro shows fho fnIIuro rnfos of fho vnrIous comononfs of
TorfInry Isk. In ndvnnco of buIIdIng fho sysfom, fho dosIgnors nssumod fhnf dnfn
dIsks wouId bo fho Ionsf roIInbIo nrf of fho sysfom, ns fhoy nro bofh mochnnIcnI nnd
IonfIfuI.
As TorfInry Isk wns n Inrgo sysfom wIfh mnny rodundnnf comononfs, If hnd
fho ofonfInI fo survIvo fhIs wIdo rnngo of fnIIuros. Comononfs woro connocfod nnd
mIrrorod Imngos woro Incod no sIngIo fnIIuro couId mnko nny Imngo unnvnIInbIo. ThIs
sfrnfogy, whIch InIfInIIy nonrod fo bo ovorkIII, rovod fo bo vIfnI.
Computev AvcLItectuve
TLunguveI Muvugun 261
Component
TotuI In
System
TotuI
IuIIed
"
IuIIed
SCSI ConfroIIor 44 l 2.3
SCSI CnbIo 39 l 2.6
SCSI Isk 368 ? l.9
II Isk 24 6 25.0
Isk IncIosuro -
InckInno
46 l3 28.3
Isk IncIosuro -
Iowor SuIy

92

3

3.3
Ifhornof ConfroIIor 20 l 5.0
Ifhornof SwIfch 2 l 50.0
Ifhornof CnbIo 42 l 2.3
CI!/Mofhorbonrd 20 0 0

IuIIuves oI components In TevtIuvy Isk ovev eIgLteen montLs oI opevutIon.

ThIs oxorIonco nIso domonsfrnfod fho dIfforonco bofwoon frnnsIonf fnuIfs nnd
hnrd fnuIfs. TroneienI foulIe nro fnuIfs fhnf como nnd go, nf Ionsf fomornrIIy fIxIng
fhomsoIvos. HorJ foulIe sfo fho dovIco from workIng roorIy, nnd wIII confInuo fo
mIsbohnvo unfII ronIrod.
Tundem
Tho noxf oxnmIo comos from Indusfry. Crny |l990] coIIocfod dnfn on fnuIfs for
Tnndom Comufors, whIch wns ono of fho IonoorIng comnnIos In fnuIf foIornnf
comufIng. IIguro ?.2l grnhs fho fnuIfs fhnf cnusod sysfom fnIIuros bofwoon l985 nnd
l989 In nbsoIufo fnuIfs or sysfom nnd In orconfngo of fnuIfs oncoun-forod. Tho dnfn
shows n cIonr Imrovomonf In fho roIInbIIIfy of hnrdwnro nnd mnInfonnnco.
Isks In l985 noodod yonrIy sorvIco by Tnndom, buf fhoy woro ro-Incod by dIsks
fhnf noodod no schoduIod mnInfonnnco.
Computev AvcLItectuve
TLunguveI Muvugun 262
ShrInkIng numbor of chIs nnd connocfors or sysfom Ius soffwnro`s nbIIIfy fo
foIornfo hnrdwnro fnuIfs roducod hnrdwnro`s confrIbufIon fo onIy ? of fnIIuros by
l989. And whon hnrdwnro wns nf fnuIf, soffwnro omboddod In fho hnrdwnro dovIco
(frmwnro) wns offon fho cuIrIf. Tho dnfn IndIcnfos fhnf soffwnro In l989 wns fho
mnjor sourco of roorfod oufngos (62), foIIowod by sysfom oornfIons (l5).


Computev AvcLItectuve
TLunguveI Muvugun 263
Tho robIoms wIfh nny such sfnfIsfIcs nro fhnf fhoso dnfn onIy rofor fo whnf Is
roorfod; for oxnmIo, onvIronmonfnI fnIIuros duo fo owor oufngos woro nof roorfod fo
Tnndom bocnuso fhoy woro soon ns n IocnI robIom.
VAX
Tho noxf oxnmIo Is nIso from Indusfry. Murhy nnd Conf |l995] monsurod
fnuIfs In VAX sysfoms. Thoy cInssIfIod fnuIfs ns hnrdwnro, oornfIng sysfom, sysfom
mnnngomonf, or nIIcnfIon/nofworkIng. IIguro shows fhoIr dnfn for l985 nnd l993.
Thoy frIod fo Imrovo fho nccurncy of dnfn on oornfor fnuIfs by hnvIng fho
sysfom nufomnfIcnIIy romf fho oornfor on onch boof for fho ronson for fhnf roboof.
Thoy nIso cInssIfIod consocufIvo crnshos fo fho snmo fnuIf ns oornfor fnuIf. ofo fhnf
fho hnrdwnro/oornfIng sysfom wonf from cnusIng ?0 of fho fnIIuros In l985 fo 28 In
l993. Murhy nnd Conf oxocfod sysfom mnnngomonf fo bo fho rImnry doondnbIIIfy
chnIIongo In fho fufuro.


Computev AvcLItectuve
TLunguveI Muvugun 264
ICC
Tho fInnI sof of dnfn comos from fho govornmonf. Tho IodornI CommunIcnfIons
CommIssIon (ICC) roquIros fhnf nII foIohono comnnIos submIf oxInnnfIons whon
fhoy oxorIonco nn oufngo fhnf nffocfs nf Ionsf 30,000 ooIo or Insfs fhIrfy mInufos.
Thoso dofnIIod dIsrufIon roorfs do nof suffor from fho soIf-roorfIng robIom of
onrIIor fIguros, ns InvosfIgnfors doformIno fho cnuso of fho oufngo rnfhor fhnn oornfors
of fho oquImonf.
Kuhn |l99?] sfudIod fho cnusos of oufngos bofwoon l992 nnd l994 nnd InrIquoz
|200l] dId n foIIow-u sfudy for fho frsf hnIf of 200l.
In nddIfIon fo roorfIng numbor of oufngos, fho ICC dnfn IncIudos fho numbor
of cusfomors nffocfod nnd how Iong fhoy woro nffocfod.
Honco, wo cnn Iook nf fho sIzo nnd scoo of fnIIuros, rnfhor fhnn nssumIng fhnf
nII nro oqunIIy Imorfnnf. IIguro Iofs fho nbsoIufo nnd roInfIvo numbor of cusfomor-
oufngo mInufos for fhoso yonrs, brokon Info four cnfogorIos:
InIIuros duo fo oxcoodIng fho nofwork`s cnncIfy (ovorIond).
InIIuros duo fo ooIo (humnn).
Oufngos cnusod by fnuIfs In fho foIohono nofwork soffwnro (soffwnro).
SwIfch fnIIuro, cnbIo fnIIuro, nnd owor fnIIuro (hnrdwnro).

Thoso four oxnmIos nnd ofhors suggosf fhnf fho rImnry cnuso of fnIIuros In
Inrgo sysfoms fodny Is fnuIfs by humnn oornfors. Hnrdwnro fnuIfs hnvo docIInod duo fo
n docronsIng numbor of chIs In sysfoms, roducod owor, nnd fowor connocfors.
Hnrdwnro doondnbIIIfy hns Imrovod fhrough fnuIf foIornnco fochnIquos such ns
!AI. Af Ionsf somo oornfIng sysfoms nro consIdorIng roIInbIIIfy ImIIcnfIons boforo
now nddIng fonfuros, so In 200l fho fnIIuros InrgoIy occur oIsowhoro.

Computev AvcLItectuve
TLunguveI Muvugun 265
4.1? I/O PRIORMANC MASURS
I/O orformnnco hns monsuros fhnf hnvo no counfornrfs In CI! dosIgn. Ono of
fhoso Is dIvorsIfy: WhIch I/O dovIcos cnn connocf fo fho comufor sysfom` Anofhor Is
cnncIfy: How mnny I/O dovIcos cnn connocf fo n comufor sysfom`
Tho frndIfIonnI monsuros of orformnnco, nnmoIy rosonso fImo nnd fhroughuf,
nIso nIy fo I/O. (I/O fhroughuf Is somofImos cnIIod 1/O IonJuiJII, nnd rosonso
fImo Is somofImos cnIIod loIenc,.). Tho roducor cronfos fnsks fo bo orformod nnd
Incos fhom In n buffor; fho sorvor fnkos fnsks from fho fIrsf-In-fIrsf-ouf buffor nnd
orforms fhom.
!osonso fImo Is dofInod ns fho fImo n fnsk fnkos from fho momonf If Is Incod In
fho buffor unfII fho sorvor fInIshos fho fnsk. Throughuf Is sImIy fho nvorngo numbor
of fnsks comIofod by fho sorvor ovor n fImo orIod.
To gof fho hIghosf ossIbIo fhroughuf, fho sorvor shouId novor bo IdIo, nnd fhus
fho buffor shouId novor bo omfy. !osonso fImo, on fho ofhor hnnd, counfs fImo sonf
In fho buffor nnd Is fhoroforo mInImIzod by fho buffor boIng omfy.
Anofhor monsuro of I/O orformnnco Is fho Inforforonco of I/O wIfh CI!
oxocufIon. TrnnsforrIng dnfn mny Inforforo wIfh fho oxocufIon of nnofhor rocoss. Thoro
Is nIso ovorhond duo fo hnndIIng I/O Inforrufs.


TLe tvudItIonuI pvoducev-sevvev modeI oI vesponse tIme und tLvougLput.


Computev AvcLItectuve
TLunguveI Muvugun 266


TLvougLput vevsus Response TIme
IIguro shows fhroughuf vorsus rosonso fImo (or Infoncy) for n fyIcnI I/O
sysfom. Tho knoo of fho curvo Is fho nron whoro n IIffIo moro fhroughuf rosuIfs In
much Iongor rosonso fImo or, convorsoIy, n IIffIo shorfor rosonso fImo rosuIfs In much
Iowor fhroughuf.

An InforncfIon, or IroneocIion, wIfh n comufor Is dIvIdod Info fhroo nrfs:
l. 1nIr, Iinefho fImo for fho usor fo onfor fho commnnd.
2. S,eIen reeponee IineTho fImo bofwoon whon fho usor onfors fho commnnd
nnd fho comIofo rosonso Is dIsInyod.
3. TIinl IineTho fImo from fho rocofIon of fho rosonso unfII fho usor bogIns fo
onfor fho noxf commnnd.
Tho sum of fhoso fhroo nrfs Is cnIIod fho IroneocIion Iine. TroneocIione per
Iour nro n monsuro of fho work comIofod or hour by fho usor.

Sysfom rosonso fImo mngnIfIod fnIonf: n novIco wIfh subsocond sysfom
rosonso fImo wns ns roducfIvo ns nn oxorIoncod rofossIonnI wIfh sIowor rosonso,
nnd fho oxorIoncod ongInoor In furn couId ouforform fho oxorf wIfh n sImIInr
ndvnnfngo In rosonso fImo.

Response TIme vs. TLvougLput In BencLmuvks
I/O bonchmnrks offor nnofhor orsocfIvo on fho rosonso fImo vs. fhroughuf
frndo-off. Tho fwo roorfIng nronchos roorf mnxImum fhroughuf gIvon oIfhor fhnf
90 of rosonso fImos musf bo Ioss fhnn n IImIf or fhnf fho nvorngo rosonso fImo musf
bo Ioss fhnn n IImIf.

Computev AvcLItectuve
TLunguveI Muvugun 26?

TLvougLput vevsus vesponse tIme.

Response tIme vestvIctIons Iov tLvee I/O BencLmuvks.

4.1? BNCHMARKS OI STORAG PRIORMANC AN AVAIIABIIITY
TvunsuctIon PvocessIng BencLmuvks
TroneocIion proceeeing (TI, or O!TI for on-IIno frnnsncfIon rocossIng) Is chIofIy
concornod wIfh 1/O roIe: fho numbor of dIsk nccossos or socond, ns oosod fo JoIo
roIe, monsurod ns byfos of dnfn or socond. TI gonornIIy InvoIvos chnngos fo n Inrgo
body of shnrod InformnfIon from mnny formInnIs, wIfh fho TI sysfom gunrnnfooIng
roor bohnvIor on n fnIIuro. Suoso, for oxnmIo, n bnnk`s comufor fnIIs whon n
cusfomor frIos fo wIfhdrnw monoy.
Computev AvcLItectuve
TLunguveI Muvugun 26B

Tho TI sysfom wouId gunrnnfoo fhnf fho nccounf Is dobIfod If fho cusfomor
rocoIvod fho monoy onJ fhnf fho nccounf Is unchnngod If fho monoy wns nof rocoIvod.
AIrIIno rosorvnfIons sysfoms ns woII ns bnnks nro frndIfIonnI cusfomors for TI.ThIs
roorf Iod fo fho TroneocIion Proceeeing Council, whIch In furn hns Iod fo sovon
bonchmnrks sInco Ifs foundIng.Tho TIC bonchmnrks woro oIfhor fho fIrsf, nnd In somo
cnsos sfIII fho onIy onos, fhnf hnvo fhoso unusunI chnrncforIsfIcs:
Price ie incluJeJ uiII IIe IencInorl reeulIe. Tho cosf of hnrdwnro, soffwnro, nnd
fIvo-yonr mnInfonnnco ngroomonfs Is IncIudod In n submIssIon, whIch on-nbIos
ovnIunfIons bnsod on rIco-orformnnco ns woII ns hIgh orformnnco.
TIe JoIo eeI generoll, nueI ecole in eice oe IIe IIrougIpuI increoeee. Tho
bonchmnrks nro fryIng fo modoI ronI sysfoms, In whIch fho domnnd on fho sys-fom nnd
fho sIzo of fho dnfn sforod In If Incronso fogofhor. If mnkos no sonso, for oxnmIo, fo
hnvo fhousnnds of ooIo or mInufo nccoss hundrods of bnnk nc-counfs.
TIe IencInorl reeulIe ore ouJiIeJ. Ioforo rosuIfs cnn bo submIffod, fhoy musf
bo nrovod by n corfIfod TIC nudIfor, who onforcos fho TIC ruIos fhnf fry fo mnko
suro fhnf onIy fnIr rosuIfs nro submIffod. !osuIfs cnn bo chnIIongod nnd dIsufos
rosoIvod by goIng boforo fho TIC councII.
TIrougIpuI ie IIe perfornonce neIric IuI reeponee Iinee ore liniIeJ. Ior ox-
nmIo, wIfh TIC-C, 90 of fho ow-Ordor frnnsncfIon rosonso fImos musf bo Ioss
fhnn 5 soconds.
An inJepenJenI orgonicoIion noinIoine IIe IencInorle. uos coIIocfod by TIC
ny for nn ndmInIsfrnfIvo sfrucfuro IncIudIng n ChIof OornfIng Offco. ThIs
orgnnIznfIon soffIos dIsufos, conducfs mnII bnIIofs on nrovnI of chnngos fo
bonchmnrks, hoId bonrd moofIngs, nnd so on.

Computev AvcLItectuve
TLunguveI Muvugun 269
BencLmuvk
utu SIze
(GB)
PevIovmunce
MetvIc
ute oI IIvst
ResuIts
A: obIf CrodIf (rofIrod) 0.l fo l0
frnnsncfIons or
socond
JuIy, l990
I: Infch obIf CrodIf
(rofIrod)
0.l fo l0
frnnsncfIons or
socond
JuIy, l99l
C: ComIox Quory O!TI l00 fo 3000
(mInImum 0.0?
* fm)
now ordor
frnnsncfIons or
mInufo
Sofombor,
l992
: ocIsIon Suorf
(rofIrod)
l00, 300, l000 quorIos or hour
ocombor,
l995
H: Ad hoc docIsIon
suorf
l00, 300, l000 quorIos or hour Ocfobor, l999
!: IusInoss roorfIng
docIsIon suorf
l000 quorIos or hour Augusf, l999
W: TrnnsncfIonnI wob
bonchmnrk
- 50, 500 wob InforncfIons
or socond
JuIy, 2000
TvunsuctIon PvocessIng CouncII BencLmuvks.

SPC System-IeveI IIIe Sevvev (SIS) und Web BencLmuvks
Tho SIIC bonchmnrkIng offorf Is bosf known for Ifs chnrncforIznfIon of
rocossor orformnnco, buf hns cronfod bonchmnrks for ofhor fIoIds ns woII. In l990
sovon comnnIos ngrood on n synfhofIc bonchmnrk, cnIIod SIS, fo ovnIunfo sysfoms
runnIng fho Sun MIcrosysfoms nofwork fIIo sorvIco IS. ThIs bonchmnrk wns
ugrndod fo SIS 2.0 (nIso cnIIod SIIC SIS9?) fo IncIudo suorf for SI vorsIon 3,
usIng TCI In nddIfIon fo !I ns fho frnnsorf rofocoI, nnd mnkIng fho mIx of
oornfIons moro ronIIsfIc.



Computev AvcLItectuve
TLunguveI Muvugun 2?0

IIguro shows nvorngo rosonso fImo vorsus fhroughuf for four sysfoms.
!nforfunnfoIy, unIIko fho TIC bonchmnrks, SIS doos nof normnIIzo for dIfforonf rIco
confIgurnfIons. Tho fnsfosf sysfom In IIguro hns ? fImos fho numbor of CI!s nnd dIsks
ns fho sIowosf sysfom, buf SIIC Ionvos If fo you fo cnIcuInfo rIco vorsus orformnnco.
As orformnnco scnIod fo now hoIghfs, SIIC dIscovorod bugs In fho bonchmnrk
fhnf Imncf fho nmounf of work dono durIng fho monsuromonf orIods. Honco, If wns
rofIrod In Juno 200l.
SIIC WII Is n bonchmnrk for ovnIunfIng fho orformnnco of WorId WIdo Wob
sorvors. Tho SIIC WII99 workIond sImuInfos nccossos fo n wob sorvIco rovIdor,
whoro fho sorvor suorfs homo ngos for sovornI orgnnIznfIons. Inch homo ngo Is n
coIIocfIon of fIos rnngIng In sIzo from smnII Icons fo Inrgo docu-monfs nnd Imngos, wIfh
somo fIos boIng moro ouInr fhnn ofhors. Tho workIond dofnos four sIzos of fIos nnd
fhoIr froquoncy of ncfIvIfy:
Ioss fhnn l KI, rorosonfIng nn smnII Icon: 35 of ncfIvIfy
l fo l0 KI: 50 of ncfIvIfy
l0 fo l00 KI: l4 of ncfIvIfy
l00 KI fo l MI: rorosonfIng n Inrgo documonf nnd Imngo,l of ncfIvIfy

IIguro shows rosuIfs for oII comufors. Tho orformnnco rosuIf rorosonfs fho
numbor of sImuIfnnoous connocfIons fho wob sorvor cnn suorf usIng fho rodofInod
workIond. As fho dIsk sysfom Is fho snmo, If nonrs fhnf fho Inrgo momory Is usod for
n fIIo cncho fo roduco dIsk I/O. SIIC WII99 rosuIfs In 2000 for oII comufors. Inch
mnchIno usos fIvo 9CI, l0,000 !IM dIsks oxcof fho fIffh sysfom, whIch hnd sovon
dIsks. Tho fIrsf four hnvo 256 KI of !2 cncho whIIo fho Insf fwo hnvo 2 MI of !2 cncho.
Computev AvcLItectuve
TLunguveI Muvugun 2?1

System
Nume
ResuIt CPUs ResuIt/
CPU
HTTP
VevsIon/OS
PentIum
III
RAM
IoworIdgo
2400/66?
?32 l ?32
IIS
5.0/WIndows
2000
66? MHz
II
2 CI
IoworIdgo
2400/66?
l2?0 l l2?0
T!X l.0/!od
Hnf !Inux 6.2
66? MHz
II
2 CI
IoworIdgo
4400/800
l060 2 530
IIS
5.0/WIndows
2000
800 MHz
II
4 CI
IoworIdgo
4400/800
2200 2 ll00
T!X l.0/!od
Hnf !Inux 6.2
800 MHz
II
4 CI
IoworIdgo
6400/?00
l598 4 400
IIS
5.0/WIndows
2000
?00 MHz
Xoon
8 CI
IoworIdgo
6400/?00
4200 4 l050
T!X l.0/!od
Hnf !Inux 6.2
?00 MHz
Xoon
8 CI

Computev AvcLItectuve
TLunguveI Muvugun 2?2
4.1B SIGN AN I/O SYSTM IN IIV ASY PICS
Tho nrf of I/O sysfom dosIgn Is fo fInd n dosIgn fhnf moofs gonIs for cosf, doond-
nbIIIfy, nnd vnrIofy of dovIcos whIIo nvoIdIng boffIonocks fo I/O orformnnco. AvoIdIng
boffIonocks monns fhnf comononfs musf bo bnInncod bofwoon mnIn momory nnd fho
I/O dovIco, bocnuso orformnnco nnd honco offocfIvo cosf/orformnnco cnn onIy bo ns
good ns fho wonkosf IInk In fho I/O chnIn. IInnIIy, sforngo musf bo doondnbIo, nddIng
now consfrnInfs on roosod dosIgns. In dosIgnIng nn I/O sysfom, nnnIyzo orformnnco,
cosf, cnncIfy, nnd nvnIInbIIIfy usIng vnryIng I/O connocfIon schomos nnd dIfforonf
numbors of I/O dovIcos of onch fyo. Horo Is ono sorIos of sfos fo foIIow In dosIgnIng nn
I/O sysfom. Tho nnswors for onch sfo mny bo dIcfnfod by mnrkof roquIromonfs or
sImIy by cosf, orformnnco, nnd nvnIInbIIIfy gonIs.
l. !Isf fho dIfforonf fyos of I/O dovIcos fo bo connocfod fo fho mnchIno, or IIsf
fho sfnndnrd busos fhnf fho mnchIno wIII suorf.
2. !Isf fho hysIcnI roquIromonfs for onch I/O dovIco. !oquIromonfs IncIudo
sIzo, owor, connocfors, bus sIofs, oxnnsIon cnbInofs, nnd so on.
3. !Isf fho cosf of onch I/O dovIco, IncIudIng fho orfIon of cosf of nny confroIIor
noodod for fhIs dovIco.
4. !Isf fho roIInbIIIfy of onch I/O dovIco.
5. !ocord fho CI! rosourco domnnds of onch I/O dovIco. ThIs IIsf shouId IncIudo
o CIock cycIos for InsfrucfIons usod fo InIfInfo nn I/O, fo suorf
oornfIon of nn I/O dovIco (such ns hnndIIng Inforrufs), nnd comIofo
I/O
o CI! cIock sfnIIs duo fo wnIfIng for I/O fo fInIsh usIng fho momory,
bus, or cncho. CI! cIock cycIos fo rocovor from nn I/O ncfIvIfy, such ns
n cncho fIush.
6. !Isf fho momory nnd I/O bus rosourco domnnds of onch I/O dovIco. Ivon whon
fho CI! Is nof usIng momory, fho bnndwIdfh of mnIn momory nnd fho I/O bus Is
IImIfod.
?. Tho fInnI sfo Is nssossIng fho orformnnco nnd nvnIInbIIIfy of fho dIfforonf
wnys fo orgnnIzo fhoso I/O dovIcos.
Computev AvcLItectuve
TLunguveI Muvugun 2?3
Iorformnnco cnn onIy bo roorIy ovnIunfod wIfh sImuInfIon, fhough If mny bo
osfImnfod usIng quouIng fhoory. !oIInbIIIfy cnn bo cnIcuInfod nssumIng I/O dovIcos fnII
IndoondonfIy nnd nro fhnf MTTIs nro oxononfInIIy dIsfrIbufod. AvnIInbIIIfy cnn bo
comufod from roIInbIIIfy by osfImnfIng MTTI for fho dovIcos, fnkIng Info nccounf fho
fImo from fnIIuro fo ronIr.
You fhon soIocf fho bosf orgnnIznfIon, gIvon your cosf, orformnnco, nnd nvnII-
nbIIIfy gonIs. Cosf/orformnnco gonIs nffocf fho soIocfIon of fho I/O schomo nnd hysIcnI
dosIgn. Iorformnnco cnn bo monsurod oIfhor ns mognbyfos or socond or I/Os or
socond, doondIng on fho noods of fho nIIcnfIon.
Ior hIgh orformnnco, fho onIy IImIfs shouId bo sood of I/O dovIcos, numbor of
I/O dovIcos, nnd sood of momory nnd CI!. Ior Iow cosf, fho onIy oxonsos shouId bo
fhoso for fho I/O dovIcos fhomsoIvos nnd for cnbIIng fo fho CI!. Cosf/orformnnco
dosIgn, of courso, frIos for fho bosf of bofh worIds.
AvnIInbIIIfy gonIs doond In nrf on fho cosf of unnvnIInbIIIfy fo nn
orgnnIznfIon.To mnko fhoso Idons cIonror, fho noxf dozon ngos go fhrough fvo
oxnmIos. Inch Iooks nf consfrucfIng n dIsk nrrny wIfh nbouf 2 fornbyfos of cnncIfy for
usor dnfn wIfh fwo sIzos of dIsks. To offor n gonfIo InfroducfIon fo I/O dosIgn nnd ovnI-
unfIon, fho oxnmIos ovoIvo In ronIIsm.
To fry fo nvoId goffIng Iosf In fho dofnIIs, Iof`s sfnrf wIfh nn ovorvIow of fho fvo
oxnmIos:
l. uite coot-performunce Jeoign unJ etuluution: Tho fIrsf oxnmIo cnIcuInfos
cosf-orformnnco of nn I/O sysfom for fho fwo fyos of dIsks. If Ignoros do-
ondnbIIIfy concorns, nnd mnkos fho sImIIfyIng nssumfIon of nIIowIng l00
ufIIIznfIon of I/O rosourcos. ThIs oxnmIo Is nIso fho Iongosf.

2. Atuilubility of the firot erumple: Tho socond oxnmIo cnIcuInfos fho oor
nvnIInbIIIfy of fhIs nnIvo I/O dosIgn.

3. Reoponoe timeo of the firot erumple: Tho fhIrd oxnmIo usos quouIng fhoory
fo cnIcuInfo fho Imncf on rosonso fImo of fryIng fo uso l00 of nn I/O rosourco.
Computev AvcLItectuve
TLunguveI Muvugun 2?4
4. More reuliotic coot-performunce Jeoign unJ etuluution: SInco fho fhIrd
oxnmIo shows fho foIIy of l00 ufIIIznfIon, fho fourfh oxnmIo chnngos fho
dosIgn fo oboy common ruIos of fhumb on ufIIIznfIon of I/O rosourcos. If fhon
ovnIunfos cosf-orformnnco.

5. More reuliotic Jeoign for utuilubility unJ ito etuluution: SInco fho socond
oxnmIo shows fho oor nvnIInbIIIfy whon doondnbIIIfy Is Ignorod, fhIs fInnI ox-
nmIo usos n !AI 5 dosIgn. If fhon cnIcuInfos nvnIInbIIIfy nnd orformnnco.

***N***
















Computev AvcLItectuve
TLunguveI Muvugun 2?5
UNIT V
MUITIPROCSSORS AN THRA-IVI PARAIIIISM

5.1 INTROUCTION
Wo boIIovo fhnf nrnIIoI rocossors wIII dofInIfoIy hnvo n bIggor roIo In fho
fufuro. ThIs vIow Is drIvon by fhroo obsorvnfIons.

(l) SInco mIcrorocossors nro IIkoIy fo romnIn fho domInnnf unIrocossor
fochnoIogy, fho IogIcnI wny fo Imrovo orformnnco boyond n sIngIo rocossor Is
by connocfIng muIfIIo mIcrorocossors fogofhor.
(2) If Is uncIonr whofhor fho nco of nrchIfocfurnI InnovnfIon fhnf hns boon bnsod for
moro fhnn fIffoon yonrs on Incronsod oxIoIfnfIon of InsfrucfIon-IovoI nrnIIoIIsm
cnn bo susfnInod IndofInIfoIy.
(3) Thoro nonrs fo bo sIow buf sfondy rogross on fho mnjor obsfncIo fo
wIdosrond uso of nrnIIoI rocossors, nnmoIy soffwnro.

Sorvor nnd omboddod nIIcnfIons oxhIbIf nnfurnI nrnIIoIIsm fhnf cnn bo
oxIoIfod wIfhouf somo of fho burdons of rowrIfIng n gIgnnfIc soffwnro bnso. ThIs Is
moro of n chnIIongo In fho doskfo snco.

Two PvobIems:
l) MuIfIrocossor nrchIfocfuro Is n Inrgo nnd dIvorso fIoId, nnd much of fho
fIoId Is In Ifs youfh, wIfh Idons comIng nnd goIng nnd, unfII vory roconfIy,
moro nrchIfocfuros fnIIIng fhnn succoodIng.
2) Such covorngo wouId nocossnrIIy onfnII dIscussIng nronchos fhnf mny
nof sfnnd fho fosf of fImo, somofhIng wo hnvo InrgoIy nvoIdod fo fhIs
oInf.
Ior fhoso ronsons, wo hnvo choson fo focus on fho mnInsfronm of muIfIrocossor dosIgn:
muIfIrocossors wIfh smnII fo modIum numbors of rocossors (<=l28). Such dosIgns
vnsfIy domInnfo In forms of bofh unIfs nnd doIInrs.
Computev AvcLItectuve
TLunguveI Muvugun 2?6
Tuonomy oI PuvuIIeI AvcLItectuves
Tho Idon of usIng muIfIIo rocossors bofh fo Incronso orformnnco nnd fo
Imrovo nvnIInbIIIfy dnfos bnck fo fho onrIIosf oIocfronIc comufors.
Tho nrnIIoIIsm In fho InsfrucfIon nnd dnfn sfronms cnIIod for by fho InsfrucfIons
nf fho mosf consfrnInod comononf of fho muIfIrocossor, nnd Incod nII comufors In
ono of four cnfogorIos:

Single inotruction otreum, oingle Jutu otreum (SIS)fhIs cnfogory Is fho
unIrocossor.
Single inotruction otreum, multiple Jutu otreumo (SIM)fho snmo
InsfrucfIon Is oxocufod by muIfIIo rocossors usIng dIfforonf dnfn sfronms. Inch
rocossor hns Ifs own dnfn momory (honco muIfIIo dnfn), buf fhoro Is n sIngIo
InsfrucfIon momory nnd confroI rocossor, whIch fofchos nnd dIsnfchos
InsfrucfIons.
Multiple inotruction otreumo, oingle Jutu otreum (MIS)o commorcInI
muIfIrocossor of fhIs fyo hns boon buIIf fo dnfo, buf mny bo In fho fufuro. Somo
socInI uroso sfronm rocossors nroxImnfo n IImIfod form of fhIs (fhoro Is
onIy n sIngIo dnfn sfronm fhnf Is oornfod on by succossIvo funcfIonnI unIfs).
Multiple inotruction otreumo, multiple Jutu otreumo (MIM)onch
rocossor fofchos Ifs own InsfrucfIons nnd oornfos on Ifs own dnfn. Tho
rocossors nro offon off-fho-shoIf mIcrorocossors.

Mnny of fho onrIy muIfIrocossors woro SIM. MIM hns cIonrIy omorgod ns fho
nrchIfocfuro of choIco for gonornI-uroso muIfIrocossors. Two Iuctovs nro rImnrIIy
rosonsIbIo for fho rIso of fho MIM muIfIrocossors:

l. MIMs offor fIoxIbIIIfy. WIfh fho corrocf hnrdwnro nnd soffwnro suorf,
MIMs cnn funcfIon ns sIngIo-usor muIfIrocossors focusIng on hIgh
orformnnco for ono nIIcnfIon, ns muIfIrogrnmmod muIfIrocossors runnIng
mnny fnsks sImuIfnnoousIy, or ns somo combInnfIon of fhoso funcfIons.
Computev AvcLItectuve
TLunguveI Muvugun 2??
2. MIMs cnn buIId on fho cosf/orformnnco ndvnnfngos of off-fho-shoIf
mIcrorocossors. In fncf, nonrIy nII muIfIrocossors buIIf fodny uso fho snmo
mIcrorocossors found In worksfnfIons nnd sIngIo-rocossor sorvors.

A rocoss Is n sogmonf of codo fhnf mny bo run IndoondonfIy, nnd fhnf fho sfnfo
of fho rocoss confnIns nII fho InformnfIon nocossnry fo oxocufo fhnf rogrnm on n
rocossor. In n muIfIrogrnmmod onvIronmonf, whoro fho rocossors mny bo runnIng
Indoondonf fnsks, onch rocoss Is fyIcnIIy Indoondonf of fho rocossos on ofhor
rocossors. If Is nIso usofuI fo bo nbIo fo hnvo muIfIIo rocossors oxocufIng n sIngIo
rogrnm nnd shnrIng fho codo nnd mosf of fhoIr nddross snco. Whon muIfIIo
rocossos shnro codo nnd dnfn In fhIs wny, fhoy nro offon cnIIod IIreoJe.To fnko
ndvnnfngo of nn MIM muIfIrocossor wIfh n rocossors, wo musf usunIIy hnvo nf Ionsf
n fhronds or rocossos fo oxocufo. Tho Indoondonf fhronds nro fyIcnIIy IdonfIfIod by
fho rogrnmmor or cronfod by fho comIIor. SInco fho nrnIIoIIsm In fhIs sIfunfIon Is
confnInod In fho fhronds, If Is cnIIod threuJ-letel purulleliom.
Tho Imorfnnf qunIIfnfIvo dIsfIncfIon Is fhnf such nrnIIoIIsm Is IdonfIfIod nf n
hIgh-IovoI by fho soffwnro sysfom nnd fhnf fho fhronds consIsf of hundrods fo mIIIIons
of InsfrucfIons fhnf mny bo oxocufod In nrnIIoI. In confrnsf, InsfrucfIonIovoI
nrnIIoIIsm Is IdonfIfIod by rImnrIIy by fho hnrdwnro, fhough wIfh soffwnro hoI In
somo cnsos, nnd Is found nnd oxIoIfod ono InsfrucfIon nf n fImo.Tho fIrsf grou, whIch
wo cnII centrulixeJ ohureJ-memory urchitectureo, hnvo nf mosf n fow dozon
rocossors In 2000. Ior muIfIrocossors wIfh smnII rocossor counfs, If Is ossIbIo for
fho rocossors fo shnro n sIngIo confrnIIzod momory nnd fo Inforconnocf fho rocossors
nnd momory by n bus.
WIfh Inrgo cnchos, fho bus nnd fho sIngIo momory, ossIbIy wIfh muIfIIo bnnks,
cnn snfIsfy fho momory domnnds of n smnII numbor of rocossors. Iy roIncIng n sIngIo
bus wIfh muIfIIo busos, or ovon n swIfch, n confrnIIzod shnrod momory dosIgn cnn bo
scnIod fo n fow dozon rocossors. AIfhough scnIIng boyond fhnf Is fochnIcnIIy
concoIvnbIo, shnrIng n confrnIIzod momory, ovon orgnnIzod ns muIfIIo bnnks, bocomos
Ioss nffrncfIvo ns fho numbor of rocossors shnrIng If Incronsos.
Computev AvcLItectuve
TLunguveI Muvugun 2?B
Iocnuso fhoro Is n sIngIo mnIn momory fhnf hns n symmofrIc roInfIonshI fo nII
rocossors nnd n unIform nccoss fImo from nny rocossor, fhoso muIfIrocossors nro
offon cnIIod oymmetric (ohureJ-memory) multiproceoooro (SMPe), nnd fhIs sfyIo of
nrchIfocfuro Is somofImos cnIIod UMA for uniform memory ucceoo.
ThIs fyo of confrnIIzod shnrod-momory nrchIfocfuro Is curronfIy by fnr fho mosf
ouInr orgnnIznfIon.Tho socond grou consIsfs of muIfIrocossors wIfh hysIcnIIy
dIsfrIbufod momory. To suorf Inrgor rocossor counfs, momory musf bo dIsfrIbufod
nmong fho rocossors rnfhor fhnn confrnIIzod; ofhorwIso fho momory sysfom wouId nof
bo nbIo fo suorf fho bnndwIdfh domnnds of n Inrgor numbor of rocossors wIfhouf
IncurrIng oxcossIvoIy Iong nccoss Infoncy.
Iofh dIrocf InforconnocfIon nofworks (I.o., swIfchos) nnd IndIrocf nofworks
(fyIcnIIy muIfIdImonsIonnI moshos) nro usod.

BusIc stvuctuve oI u centvuIIzed sLuved-memovy muItIpvocessov
IsfrIbufIng fho momory nmong fho nodos hns fwo mnjor bonofIfs.
l) If Is n cosf-offocfIvo wny fo scnIo fho momory bnndwIdfh, If mosf of fho
nccossos nro fo fho IocnI momory In fho nodo.
2) If roducos fho Infoncy for nccossos fo fho IocnI momory.
Computev AvcLItectuve
TLunguveI Muvugun 2?9
Tho koy dIsndvnnfngo for dIsfrIbufod momory nrchIfocfuro Is fhnf
communIcnfIng dnfn bofwoon rocossors bocomos somowhnf moro comIox nnd hns
hIghor Infoncy, nf Ionsf whon fhoro Is no confonfIon, bocnuso fho rocossors no Iongor
shnro n sIngIo confrnIIzod momory.

TLe busIc uvcLItectuve oI u dIstvIbuted-memovy muItIpvocessov consIsts oI
IndIvIduuI nodes contuInIng u pvocessov, some memovy, typIcuIIy some I/O,
und un IntevIuce to un IntevconnectIon netwovk tLut connects uII tLe nodes.

ModeIs Iov CommunIcutIon und Memovy AvcLItectuve
Any Inrgo-scnIo muIfIrocossor musf uso muIfIIo momorIos fhnf nro hysIcnIIy
dIsfrIbufod wIfh fho rocossors. Thoro nro fwo nIfornnfIvo nrchIfocfurnI nronchos
fhnf dIffor In fho mofhod usod for communIcnfIng dnfn nmong rocossors.
In fho fIrsf mofhod, communIcnfIon occurs fhrough n shnrod nddross snco. Thnf
Is, fho hysIcnIIy sonrnfo momorIos cnn bo nddrossod ns ono IogIcnIIy shnrod nddross
snco, monnIng fhnf n momory roforonco cnn bo mndo by nny rocossor fo nny momory
IocnfIon, nssumIng If hns fho corrocf nccoss rIghfs.
Thoso muIfIrocossors nro cnIIod JiotributeJ ohureJ-memory (DSM)
nrchIfocfuros. Tho form ohureJ memory rofors fo fho fncf fhnf fho oJJreee epoce Is
shnrod; fhnf Is, fho snmo hysIcnI nddross on fwo rocossors rofors fo fho snmo IocnfIon
In momory.
Computev AvcLItectuve
TLunguveI Muvugun 2B0
Shnrod momory doos noI monn fhnf fhoro Is n sIngIo, confrnIIzod momory. In
confrnsf fo fho symmofrIc shnrod-momory muIfIrocossors, nIso known ns !MAs
(unIform momory nccoss), fho SM muIfIrocossors nro nIso cnIIod AUMAe, non-
uniforn nenor, occeee, sInco fho nccoss fImo doonds on fho IocnfIon of n dnfn word In
momory.Inch rocossor-momory moduIo Is ossonfInIIy n sonrnfo comufor; fhoroforo
fhoso nrnIIoI rocossors hnvo boon cnIIod nulIiconpuIere. As oInfod ouf In fho
rovIous chnfor, n muIfIcomufor cnn ovon consIsf of comIofoIy sonrnfo comufors
connocfod on n IocnI nron nofwork, whIch, fodny, nro ouInrIy cnIIod clueIere.
Ior n muIfIrocossor wIfh n shnrod nddross snco, fhnf nddross snco cnn bo
usod fo communIcnfo dnfn ImIIcIfIy vIn Iond nnd sforo oornfIons; honco fho nnmo
eIoreJ nenor, for such muIfIrocossors. Ior n muIfIrocossor wIfh muIfIIo nddross
sncos, communIcnfIon of dnfn Is dono by oxIIcIfIy nssIng mossngos nmong fho
rocossors. Thoroforo, fhoso muIfIrocossors nro offon cnIIod neeeoge poeeing
nulIiproceeeore.
In mossngo nssIng muIfIrocossors, communIcnfIon occurs by sondIng mossngos
fhnf roquosf ncfIon or doIIvor dnfn. If ono rocossor wnnfs fo nccoss or oornfo on dnfn
In n romofo momory, If cnn sond n mossngo fo roquosf fho dnfn or fo orform somo
oornfIon on fho dnfn.
In such cnsos, fho mossngo cnn bo fhoughf of ns n renoIe proceJure coll (IPC).
Whon fho dosfInnfIon rocossor rocoIvos fho mossngo, oIfhor by oIIIng for If or vIn nn
Inforruf, If orforms fho oornfIon or nccoss on bohnIf of fho romofo rocossor nnd
rofurns fho rosuIf wIfh n roIy mossngo.
ThIs fyo of mossngo nssIng Is nIso cnIIod e,ncIronoue, sInco fho InIfInfIng
rocossor sonds n roquosf nnd wnIfs unfII fho roIy Is rofurnod boforo confInuIng.

PevIovmunce MetvIcs Iov CommunIcutIon MecLunIsms
Throo orformnnco mofrIcs nro crIfIcnI In nny communIcnfIon mochnnIsm:
l. Communicution bunJuiJthIdonIIy fho communIcnfIon bnndwIdfh Is IImIfod
by rocossor, momory, nnd InforconnocfIon bnndwIdfhs, rnfhor fhnn by somo
nsocf of fho communIcnfIon mochnnIsm. Whon communIcnfIon occurs, rosourcos
wIfhIn fho nodos InvoIvod In fho communIcnfIon nro fIod u or occuIod,
Computev AvcLItectuve
TLunguveI Muvugun 2B1
rovonfIng ofhor oufgoIng or IncomIng communIcnfIon. Whon fhIs occunncy Is
Incurrod for onch word of n mossngo, If sofs nn nbsoIufo IImIf on fho
communIcnfIon bnndwIdfh. ThIs IImIf Is offon Iowor fhnn whnf fho nofwork or
momory sysfom cnn rovIdo.

2. Communicution lutency -- IdonIIy fho Infoncy Is ns Iow ns ossIbIo.
communIcnfIon Infoncy Is oqunI fo
Sondor ovorhond + TImo of fIIghf + TrnnsmIssIon fImo + !ocoIvor ovorhond
TImo of fIIghf Is fIxod nnd frnnsmIssIon fImo Is doformInod by fho
InforconnocfIon nofwork.

3. Communicution lutency hiJingHow woII cnn fho communIcnfIon
mochnnIsm hIdo Infoncy by ovorInIng communIcnfIon wIfh comufnfIon or
wIfh ofhor communIcnfIon` AIfhough hIdIng Infoncy Is corfnInIy n good Idon, If
osos nn nddIfIonnI burdon on fho soffwnro sysfom nnd uIfImnfoIy on fho
rogrnmmor. Thus, If Is usunIIy bosf fo roduco Infoncy whorovor ossIbIo.

Advuntuges oI IIIevent CommunIcutIon MecLunIsms
Inch of fhoso fwo rImnry communIcnfIon mochnnIsms hns Ifs ndvnnfngos. Ior shnrod-
momory communIcnfIon, ndvnnfngos IncIudo
ComnfIbIIIfy wIfh fho woII-undorsfood mochnnIsms In uso In confrnIIzod
muIfIrocossors, whIch nII uso shnrod-momory communIcnfIon.
Inso of rogrnmmIng whon fho communIcnfIon nfforns nmong rocossors nro
comIox or vnry dynnmIcnIIy durIng oxocufIon. SImIInr ndvnnfngos sImIIfy
comIIor dosIgn.
Tho nbIIIfy fo dovoIo nIIcnfIons usIng fho fnmIIInr shnrod-momory modoI,
focusIng nffonfIon onIy on fhoso nccossos fhnf nro orformnnco crIfIcnI.
!owor ovorhond for communIcnfIon nnd boffor uso of bnndwIdfh whon
communIcnfIng smnII Ifoms. ThIs nrIsos from fho ImIIcIf nnfuro of
communIcnfIon nnd fho uso of momory mnIng fo ImIomonf rofocfIon In
hnrdwnro, rnfhor fhnn fhrough fho I/O sysfom.
Computev AvcLItectuve
TLunguveI Muvugun 2B2
Tho nbIIIfy fo uso hnrdwnro-confroIIod cnchIng fo roduco fho froquoncy of romofo
communIcnfIon by suorfIng nufomnfIc cnchIng of nII dnfn, bofh shnrod nnd
rIvnfo. As wo wIII soo, cnchIng roducos bofh Infoncy nnd confonfIon for nccossIng
shnrod dnfn.

Tho mnjor udvuntuges Iov messuge-pussIng communIcutIon IncIudo
Tho hnrdwnro cnn bo sImIor, osocInIIy by comnrIson wIfh n scnInbIo shnrod
momory ImIomonfnfIon fhnf suorfs cohoronf cnchIng of romofo dnfn.
CommunIcnfIon Is oxIIcIf, whIch monns If Is sImIor fo undorsfnnd; In shnrod
momory modoIs, If cnn bo dIffIcuIf fo know whon communIcnfIon Is occurrIng nnd
whon If Is nof, ns woII ns how cosfIy fho communIcnfIon Is.
IxIIcIf communIcnfIon focusos rogrnmmor nffonfIon on fhIs cosfIy nsocf of
nrnIIoI comufnfIon, somofImos IondIng fo Imrovod sfrucfuro In n
muIfIrocossor rogrnm.
SynchronIznfIon Is nnfurnIIy nssocInfod wIfh sondIng mossngos, roducIng fho
ossIbIIIfy for orrors Infroducod by Incorrocf synchronIznfIon.
If mnkos If onsIor fo uso sondor-InIfInfod communIcnfIon, whIch mny hnvo somo
ndvnnfngos In orformnnco.

SuorfIng mossngo nssIng on fo of shnrod momory Is consIdornbIy onsIor:
Iocnuso mossngos ossonfInIIy sond dnfn from ono momory fo nnofhor, sondIng n
mossngo cnn bo ImIomonfod by doIng n coy from ono orfIon of fho nddross snco fo
nnofhor.
Tho mnjor dIffIcuIfIos nrIso from donIIng wIfh mossngos fhnf mny bo mIsnIIgnod
nnd of nrbIfrnry Iongfh In n momory sysfom fhnf Is normnIIy orIonfod fownrd
frnnsforrIng nIIgnod bIocks of dnfn orgnnIzod ns cncho bIocks. Thoso dIffIcuIfIos cnn bo
ovorcomo oIfhor wIfh smnII orformnnco onnIfIos In soffwnro or wIfh ossonfInIIy no
onnIfIos, usIng n smnII nmounf of hnrdwnro suorf. SuorfIng shnrod momory
offIcIonfIy on fo of hnrdwnro for mossngo nssIng Is much moro dIffIcuIf.

Computev AvcLItectuve
TLunguveI Muvugun 2B3
WIfhouf oxIIcIf hnrdwnro suorf for shnrod momory, nII shnrod-momory
roforoncos nood fo InvoIvo fho oornfIng sysfom fo rovIdo nddross frnnsInfIon nnd
momory rofocfIon, ns woII ns fo frnnsInfo momory roforoncos Info mossngo sonds nnd
rocoIvos. !onds nnd sforos usunIIy movo smnII nmounfs of dnfn, so fho hIgh ovorhond of
hnndIIng fhoso communIcnfIons In soffwnro sovoroIy IImIfs fho rnngo of nIIcnfIons for
whIch fho orformnnco of soffwnro- bnsod shnrod momory Is nccofnbIo.Ono ossIbIo
dIrocfIon Is fho uso of vIrfunI momory mochnnIsms fo shnro objocfs nf fho ngo IovoI, n
fochnIquo cnIIod ohureJ tirtuul memory.
Shnrod-momory communIcnfIon hns boon suorfod In vIrfunIIy ovory
muIfIrocossor dosIgnod sInco l995. Whnf hnrdwnro communIcnfIon mochnnIsms wIII
bo suorfod In fho vory Inrgosf muIfIrocossors (cnIIod noeeitel, porollel proceeeore,
or MPPe), whIch fyIcnIIy hnvo fnr moro fhnn l00 rocossors, Is uncIonr; shnrod
momory, mossngo nssIng, nnd hybrId nronchos nro nII confondors.

CLuIIenges oI PuvuIIeI PvocessIng
Two Imorfnnf hurdIos, bofh oxInInnbIo wIfh AmdnhI`s !nw, mnko nrnIIoI
rocossIng chnIIongIng.
Tho fIrsf hns fo do wIfh fho IImIfod nrnIIoIIsm nvnIInbIo In rogrnms nnd fho
socond nrIsos from fho roInfIvoIy hIgh cosf of communIcnfIons.
Tho socond mnjor chnIIongo In nrnIIoI rocossIng InvoIvos fho Inrgo Infoncy of
romofo nccoss In n nrnIIoI rocossor.
In oxIsfIng shnrod-momory muIfIrocossors, communIcnfIon of dnfn bofwoon
rocossors mny cosf nnywhoro from l00 cIock cycIos fo ovor l,000 cIock cycIos,
doondIng on fho communIcnfIon mochnnIsm, fho fyo of InforconnocfIon nofwork, nnd
fho scnIo of fho muIfIrocossor.InsuffIcIonf nrnIIoIIsm nnd Iong Infoncy romofo
communIcnfIonnro fho fwo bIggosf chnIIongos In usIng muIfIrocossors.

5.2 CHARACTRISTICS OI APPIICATION OMAINS
In nrnIIoI rocossIng, fho nddIfIonnI orformnnco-crIfIcnI chnrncforIsfIcs such
ns Iond bnInnco, synchronIznfIon, nnd sonsIfIvIfy fo momory InfoncyfyIcnIIy doond
on hIgh-IovoI chnrncforIsfIcs of fho nIIcnfIon.
Computev AvcLItectuve
TLunguveI Muvugun 2B4
Thoso chnrncforIsfIcs IncIudo fncfors IIko how dnfn Is dIsfrIbufod, fho sfrucfuro
of n nrnIIoI nIgorIfhm, nnd fho snfInI nnd fomornI nccoss nfforns fo dnfn.
Tho fhroo dIfforonf domnIns of muIfIrocossor workIonds wo oxIoro nro n
commorcInI workIond, consIsfIng of frnnsncfIon rocossIng, docIsIon suorf, nnd wob
sonrchIng; n muIfIrogrnmmod workIond wIfh oornfIng sysfoms bohnvIor IncIudod;
nnd n workIond consIsfIng of IndIvIdunI nrnIIoI rogrnms from fho fochnIcnI comufIng
domnIn.

A CommevcIuI WovkIoud

Our commorcInI workIond consIsfs of fhroo nIIcnfIons:
l. An onIIno frnnsncfIon rocossIng workIond (O!TI)
2. A docIsIon suorf sysfom (SS) workIond
3. A wob Indox sonrch (AIfnvIsfn) bonchmnrk

MuItIpvogvummIng und OS WovkIoud

Ior smnII-scnIo muIfIrocossors, fho workIond usod Is fwo Indoondonf coIos of
fho comIIo hnso of fho Androw bonchmnrk. Tho comIIo hnso consIsfs of n nrnIIoI
mnko usIng oIghf rocossors. Tho workIond Is run wIfh l28 MI of momory, nnd no
ngIng ncfIvIfy fnkos Inco.

Tho workIond hns fhroo dIsfIncf hnsos: comIIIng fho bonchmnrks, whIch
InvoIvos subsfnnfInI comufo ncfIvIfy; InsfnIIIng fho objocf fIIos In n IIbrnry; nnd
romovIng fho objocf fIIos. Tho Insf hnso Is comIofoIy domInnfod by I/O nnd onIy fwo
rocossos nro ncfIvo (ono for onch of fho runs). In fho mIddIo hnso, I/O nIso Inys n
mnjor roIo nnd fho CI! Is InrgoIy IdIo.




Computev AvcLItectuve
TLunguveI Muvugun 2B5
Ior fho workIond monsuromonfs, wo nssumo fho foIIowIng momory nnd I/O sysfoms:

IxocufIon fImo Is brokon Info four comononfs: IdIooxocufIon In fho kornoI
modo IdIo Ioo; usoroxocufIon In usor codo; synchronIznfIon oxocufIon or wnIfIng for
synchronIznfIon vnrInbIos; nnd kornoI oxocufIon In fho OS fhnf Is noIfhor IdIo nor In
synchronIznfIon nccoss.

ScIentIIIc/TecLnIcuI AppIIcutIons
Tho IIT KornoI
Tho !! KornoI
Tho Inrnos AIIcnfIon
Tho Oconn AIIcnfIon
ComufnfIon/CommunIcnfIon for fho InrnIIoI Irogrnms

5.3 SYMMTRIC SHAR MMORY ARCHITCTURS
Tho SymmofrIc Shnrod Momory ArchIfocfuro consIsfs of sovornI rocossors wIfh
n sIngIo hysIcnI momory shnrod by nII rocossors fhrough n shnrod bus.SmnII-scnIo
shnrod-momory mnchInos usunIIy suorf fho cnchIng of bofh shnrod nnd rIvnfo dnfn.
PritoIe JoIo Is usod by n sIngIo rocossor, whIIo eIoreJ JoIo Is usod by muIfIIo
rocossors; ossonfInIIy rovIdIng communIcnfIon nmong fho rocossors fhrough ronds
nnd wrIfos of fho shnrod dnfn.
Computev AvcLItectuve
TLunguveI Muvugun 2B6
Whon n rIvnfo Ifom Is cnchod, Ifs IocnfIon Is mIgrnfod fo fho cncho, roducIng fho
nvorngo nccoss fImo ns woII ns fho momory bnndwIdfh roquIrod. SInco no ofhor
rocossor usos fho dnfn, fho rogrnm bohnvIor Is IdonfIcnI fo fhnf In n unIrocossor.

CucLe CoLevence In MuItIpvocessovs:
InfroducfIon of cnchos cnusod n cohoronco robIom for I/O oornfIons; fho snmo
robIom oxIsfs In fho cnso of muIfIrocossors, bocnuso fho vIow of momory hoId by fwo
dIfforonf rocossors Is fhrough fhoIr IndIvIdunI cnchos. IIguro IIIusfrnfos fho robIom
nnd shows how fwo dIfforonf rocossors cnn hnvo fwo dIfforonf vnIuos for fho snmo
IocnfIon. ThIs dIffIcuIfy s gonornIIy roforrod fo ns fho cocIe-coIerence robIom.

TLe cucLe-coLevence pvobIem Iov u sIngIe memovy IocutIon (X), veud und
wvItten by two pvocessovs (A und B).
Wo InIfInIIy nssumo fhnf noIfhor cncho confnIns fho vnrInbIo nnd fhnf X hns fho
vnIuo l. Wo nIso nssumo n wrIfo-fhrough cncho; n wrIfo-bnck cncho ndds somo
nddIfIonnI buf sImIInr comIIcnfIons. Affor fho vnIuo of X hns boon wrIffon by A, A`s
cncho nnd fho momory bofh confnIn fho now vnIuo, buf I`s cncho doos nof, nnd If I
ronds fho vnIuo of X, If wIII rocoIvo l!
InformnIIy, wo couId sny fhnf n momory sysfom Is cohoronf If nny rond of n dnfn
Ifom rofurns fho mosf roconfIy wrIffon vnIuo of fhnf dnfn Ifom. ThIs sImIo dofInIfIon
confnIns fwo dIfforonf nsocfs of momory sysfom bohnvIor, bofh of whIch nro crIfIcnI fo
wrIfIng corrocf shnrod-momory rogrnms. Tho fIrsf nsocf, cnIIod coIerence, dofInos
whnf vnIuos cnn bo rofurnod by n rond. Tho socond nsocf, cnIIod coneieIenc,,
doformInos whon n wrIffon vnIuo wIII bo rofurnod by n rond.
Computev AvcLItectuve
TLunguveI Muvugun 2B?
A momory sysfom Is cohoronf If
A rond by n rocossor, I, fo n IocnfIon X fhnf foIIows n wrIfo by I fo X, wIfh no
wrIfos of X by nnofhor rocossor occurrIng bofwoon fho wrIfo nnd fho rond by I,
nIwnys rofurns fho vnIuo wrIffon by I.
A rond by n rocossor fo IocnfIon X fhnf foIIows n wrIfo by nnofhor rocossor fo X
rofurns fho wrIffon vnIuo If fho rond nnd wrIfo nro suffIcIonfIy sonrnfod In fImo
nnd no ofhor wrIfos fo X occur bofwoon fho fwo nccossos.
WrIfos fo fho snmo IocnfIon nro eerioliceJ: fhnf Is, fwo wrIfos fo fho snmo
IocnfIon by nny fwo rocossors nro soon In fho snmo ordor by nII rocossors. Ior
oxnmIo, If fho vnIuos l nnd fhon 2 nro wrIffon fo n IocnfIon, rocossors cnn
novor rond fho vnIuo of fho IocnfIon ns 2 nnd fhon Infor rond If ns l.

Tho fIrsf roorfy sImIy rosorvos rogrnm ordor.Tho socond roorfy dofInos
fho nofIon of whnf If monns fo hnvo n cohoronf vIow of momory: If n rocossor couId
confInuousIy rond nn oId dnfn vnIuo, wo wouId cIonrIy sny fhnf momory wns Incohoronf.
Tho nood for wrIfo sorInIIznfIon Is moro subfIo, buf oqunIIy Imorfnnf.Tho sImIosf wny
fo nvoId dIffIcuIfIos Is fo sorInIIzo wrIfos, so fhnf nII wrIfos fo fho snmo IocnfIon nro soon
In fho snmo ordor; fhIs roorfy Is cnIIod uriIe eeriolicoIion.
Cohoronco nnd consIsfoncy nro comIomonfnry: Cohoronco dofInos fho bohnvIor
of ronds nnd wrIfos fo fho snmo momory IocnfIon, whIIo consIsfoncy dofInos fho bohnvIor
of ronds nnd wrIfos wIfh rosocf fo nccossos fo ofhor momory IocnfIons.
BusIc ScLemes Iov nIovcIng CoLevence
Cohoronf cnchos rovIdo mIgrnfIon, sInco n dnfn Ifom cnn bo movod fo n IocnI
cncho nnd usod fhoro In n frnnsnronf fnshIon. ThIs mIgrnfIon roducos bofh fho Infoncy
fo nccoss n shnrod dnfn Ifom fhnf Is nIIocnfod romofoIy nnd fho bnndwIdfh domnnd on
fho shnrod momory.
Cohoronf cnchos nIso rovIdo roIIcnfIon for shnrod dnfn fhnf Is boIng
sImuIfnnoousIy rond, sInco fho cnchos mnko n coy of fho dnfn Ifom In fho IocnI cncho.
!oIIcnfIon roducos bofh Infoncy of nccoss nnd confonfIon for n rond shnrod dnfn Ifom.

Computev AvcLItectuve
TLunguveI Muvugun 2BB
Tho rofocoIs fo mnInfnIn cohoronco for muIfIIo rocossors nro cnIIod cocIe-
coIerence proIocole. Thoro nro fwo cInssos of rofocoIs, whIch uso dIfforonf fochnIquos fo
frnck fho shnrIng sfnfus, In uso:
Directory buoeJTho shnrIng sfnfus of n bIock of hysIcnI momory Is kof In jusf ono
IocnfIon, cnIIod fho JirecIor,, wo focus on fhIs nronch In socfIon 6.5, whon wo dIscuss
scnInbIo shnrod-momory nrchIfocfuro.
SnoopingIvory cncho fhnf hns n coy of fho dnfn from n bIock of hysIcnI momory
nIso hns n coy of fho shnrIng sfnfus of fho bIock, nnd no confrnIIzod sfnfo Is kof. Tho
cnchos nro usunIIy on n shnrod-momory bus, nnd nII cncho confroIIors monIfor or enoop
on fho bus fo doformIno whofhor or nof fhoy hnvo n coy of n bIock fhnf Is roquosfod on
fho bus.

SnoopIng PvotocoIs
Tho mofhod whIch onsuros fhnf n rocossor hns oxcIusIvo nccoss fo n dnfn Ifom
boforo If wrIfos fhnf Ifom. ThIs sfyIo of rofocoI Is cnIIod n uriIe intoliJoIe proIocol
bocnuso If InvnIIdnfos ofhor coIos on n wrIfo. If Is by fnr fho mosf common rofocoI,
bofh for snooIng nnd for dIrocfory schomos. IxcIusIvo nccoss onsuros fhnf no ofhor
rondnbIo or wrIfnbIo coIos of nn Ifom oxIsf whon fho wrIfo occurs: nII ofhor cnchod
coIos of fho Ifom nro InvnIIdnfod.
IIguro shows nn oxnmIo of nn InvnIIdnfIon rofocoI for n snooIng bus wIfh
wrIfo-bnck cnchos In ncfIon To soo how fhIs rofocoI onsuros cohoronco, consIdor n wrIfo
foIIowod by n rond by nnofhor rocossor: SInco fho wrIfo roquIros oxcIusIvo nccoss, nny
coy hoId by fho rondIng rocossor musf bo InvnIIdnfod (honco fho rofocoI nnmo).
Thus, whon fho rond occurs, If mIssos In fho cncho nnd Is forcod fo fofch n now coy of
fho dnfn. Ior n wrIfo, wo roquIro fhnf fho wrIfIng rocossor hnvo oxcIusIvo nccoss,
rovonfIng nny ofhor rocossor from boIng nbIo fo wrIfo sImuIfnnoousIy. If fwo
rocossors do nffomf fo wrIfo fho snmo dnfn sImuIfnnoousIy, ono of fhom wIns fho
rnco, cnusIng fho ofhor rocossor`s coy fo bo InvnIIdnfod.
Computev AvcLItectuve
TLunguveI Muvugun 2B9
Ior fho ofhor rocossor fo comIofo Ifs wrIfo, If musf obfnIn n now coy of fho
dnfn, whIch musf now confnIn fho udnfod vnIuo. Thoroforo, fhIs rofocoI onforcos wrIfo
sorInIIznfIon.

An eumpIe oI un InvuIIdutIon pvotocoI wovkIng on u snoopIng bus Iov u sIngIe
cucLe bIock (X) wItL wvIte-buck cucLes.

An eumpIe oI u wvIte updute ov bvoudcust pvotocoI wovkIng on u snoopIng
bus Iov u sIngIe cucLe bIock (X) wItL wvIte-buck cucLes.

Tho nIfornnfIvo fo nn InvnIIdnfo rofocoI Is fo udnfo nII fho cnchod coIos of n
dnfn Ifom whon fhnf Ifom Is wrIffon. ThIs fyo of rofocoI Is cnIIod n uriIe upJoIe or
uriIee IrooJcoeI rofocoI. IIguro shows nn oxnmIo of n wrIfo udnfo rofocoI In
oornfIon. In fho docndo sInco fhoso rofocoIs woro dovoIood, InvnIIdnfo hns omorgod
ns fho wInnor for fho vnsf mnjorIfy of dosIgns.

Tho orformnnco dIfforoncos bofwoon wrIfo udnfo nnd wrIfo InvnIIdnfo rofocoIs nrIso
from tLvee cLuvuctevIstIcs:
MuIfIIo wrIfos fo fho snmo word wIfh no InforvonIng ronds roquIro muIfIIo
wrIfo brondcnsfs In nn udnfo rofocoI, buf onIy ono InIfInI InvnIIdnfIon In n
wrIfo InvnIIdnfo rofocoI.
Computev AvcLItectuve
TLunguveI Muvugun 290
WIfh muIfIword cncho bIocks, onch word wrIffon In n cncho bIock roquIros n wrIfo
brondcnsf In nn udnfo rofocoI, nIfhough onIy fho fIrsf wrIfo fo nny word In fho
bIock noods fo gonornfo nn InvnIIdnfo In nn InvnIIdnfIon rofocoI. An InvnIIdnfIon
rofocoI works on cncho bIocks, whIIo nn udnfo rofocoI musf work on
IndIvIdunI words (or byfos, whon byfos nro wrIffon). If Is ossIbIo fo fry fo morgo
wrIfos In n wrIfo brondcnsf schomo.
Tho doIny bofwoon wrIfIng n word In ono rocossor nnd rondIng fho wrIffon vnIuo
In nnofhor rocossor Is usunIIy Ioss In n wrIfo udnfo schomo, sInco fho wrIffon
dnfn nro ImmodInfoIy udnfod In fho rondor`s cncho

BusIc ImpIementutIon TecLnIques
Tho sorInIIznfIon of nccoss onforcod by fho bus nIso forcos sorInIIznfIon of wrIfos,
sInco whon fwo rocossors comofo fo wrIfo fo fho snmo IocnfIon, ono musf obfnIn bus
nccoss boforo fho ofhor. Tho frsf rocossor fo obfnIn bus nccoss wIII cnuso fho ofhor
rocossor`s coy fo bo InvnIIdnfod, cnusIng wrIfos fo bo sfrIcfIy sorInIIzod. Ono
ImIIcnfIon of fhIs schomo Is fhnf n wrIfo fo n shnrod dnfn Ifom cnnnof comIofo unfII If
obfnIns bus nccoss.
Ior n wrIfo-bnck cncho, howovor, fho robIom of fIndIng fho mosf roconf dnfn
vnIuo Is hnrdor, sInco fho mosf roconf vnIuo of n dnfn Ifom cnn bo In n cncho rnfhor fhnn
In momory. HnIIy, wrIfo-bnck cnchos cnn uso fho snmo snooIng schomo bofh for
cnchos mIssos nnd for wrIfos: Inch rocossor snoos ovory nddross Incod on fho bus. If
n rocossor fInds fhnf If hns n dIrfy coy of fho roquosfod cncho bIock, If rovIdos fhnf
cncho bIock In rosonso fo fho rond roquosf nnd cnusos fho momory nccoss fo bo nborfod.
SInco wrIfo-bnck cnchos gonornfo Iowor roquIromonfs for momory bnndwIdfh, fhoy nro
gronfIy rofornbIo In n muIfIrocossor, dosIfo fho sIIghf Incronso In comIoxIfy.
Thoroforo, wo focus on ImIomonfnfIon wIfh wrIfo-bnck cnchos.
Tho normnI cncho fngs cnn bo usod fo ImIomonf fho rocoss of snooIng, nnd fho
vnIId bIf for onch bIock mnkos InvnIIdnfIon onsy fo ImIomonf. !ond mIssos, whofhor
gonornfod by nn InvnIIdnfIon or by somo ofhor ovonf, nro nIso sfrnIghfforwnrd sInco
fhoy sImIy roIy on fho snooIng cnnbIIIfy.
Computev AvcLItectuve
TLunguveI Muvugun 291

Ior wrIfos wo`d IIko fo know whofhor nny ofhor coIos of fho bIock nro cnchod,
bocnuso, If fhoro nro no ofhor cnchod coIos, fhon fho wrIfo nood nof bo Incod on fho
bus In n wrIfo-bnck cncho. of sondIng fho wrIfo roducos bofh fho fImo fnkon by fho
wrIfo nnd fho roquIrod bnndwIdfh.

An umpIe PvotocoI
A bus-bnsod cohoronco rofocoI Is usunIIy ImIomonfod by IncorornfIng n fInIfo
sfnfo confroIIor In onch nodo. ThIs confroIIor rosonds fo roquosfs from fho rocossor
nnd from fho bus, chnngIng fho sfnfo of fho soIocfod cncho bIock, ns woII ns usIng fho
bus fo nccoss dnfn or fo InvnIIdnfo If.

For oimplicity,
1. Tho rofocoI doos nof dIsfInguIsh bofwoon n wrIfo hIf nnd n wrIfo mIss fo n
shnrod cncho bIock: In bofh cnsos, wo fronf such nn nccoss ns n wrIfo mIss. Whon
fho wrIfo mIss Is Incod on fho bus, nny rocossors wIfh coIos of fho cncho bIock
InvnIIdnfo If. In n wrIfo-bnck cncho, If fho bIock Is oxcIusIvo In jusf ono cncho fhnf
cncho nIso wrIfos bnck fho bIock.
2. Tho fhroo sfnfos of fho rofocoI nro duIIcnfod fo rorosonf frnnsIfIons bnsod on
CI! roquosfs, ns oosod fo frnnsIfIons bnsod on bus roquosfs. IoIdfnco fyo Is
usod fo dIsfInguIsh fho bus ncfIons, ns oosod fo fho condIfIons on whIch n sfnfo
frnnsIfIon doonds. Tho sfnfo In onch nodo rorosonfs fho sfnfo of fho soIocfod
cncho bIock socIfIod by fho rocossor or bus roquosf.

Tho onIy dIfforonco In n muIfIrocossor wIfh cohoronco Is fhnf fho confroIIor
musf gonornfo n wrIfo mIss whon fho confroIIor hns n wrIfo hIf for n cncho bIock In fho
shnrod sfnfo. In ronIIfy, fhoro Is onIy ono fInIfo-sfnfo mnchIno or cncho, wIfh sfImuII
comIng oIfhor from fho nffnchod CI! or from fho bus.
To undorsfnnd why fhIs rofocoI works, obsorvo fhnf nny vnIId cncho bIock Is
oIfhor In fho shnrod sfnfo In muIfIIo cnchos or In fho oxcIusIvo sfnfo In oxncfIy ono
cncho.
Computev AvcLItectuve
TLunguveI Muvugun 292
Any frnnsIfIon fo fho oxcIusIvo sfnfo (whIch Is roquIrod for n rocossor fo wrIfo fo
fho bIock) roquIros n wrIfo mIss fo bo Incod on fho bus, cnusIng nII cnchos fo mnko fho
bIock InvnIId. In nddIfIon, If somo ofhor cncho hnd fho bIock In oxcIusIvo sfnfo, fhnf
cncho gonornfos n wrIfo bnck, whIch suIIos fho bIock confnInIng fho dosIrod nddross.
IInnIIy, If n rond mIss occurs on fho bus fo n bIock In fho oxcIusIvo sfnfo, fho
ownIng cncho nIso mnkos Ifs sfnfo shnrod, forcIng n subsoquonf wrIfo fo roquIro
oxcIusIvo ownorshI.


A wvIte-InvuIIdute, cucLe-coLevence pvotocoI Iov u wvIte-buck cucLe sLowIng
tLe stutes und stute tvunsItIons Iov eucL bIock In tLe cucLe.

AIfhough our sImIo cncho rofocoI Is corrocf, If omIfs n numbor of comIIcnfIons
fhnf mnko fho ImIomonfnfIon much frIckIor. Tho mosf Imorfnnf of fhoso Is fhnf fho
rofocoI nssumos fhnf oornfIons nro oIonicfhnf Is, nn oornfIon cnn bo dono In such
n wny fhnf no InforvonIng oornfIon cnn occur.
Computev AvcLItectuve
TLunguveI Muvugun 293
onnfomIc ncfIons Infroduco fho ossIbIIIfy fhnf fho rofocoI cnn JeoJlocl,
monnIng fhnf If ronchos n sfnfo whoro If cnnnof confInuo. As sfnfod onrIIor, fhIs
cohoronco rofocoI Is ncfunIIy sImIor fhnn fhoso usod In rncfIco.

CucLe-coLevence stute dIugvum wItL tLe stute tvunsItIons Induced by tLe IocuI
pvocessov sLown In bIuck und by tLe bus uctIvItIes sLown In gvuy.

Thoro nro fwo mnjor sImIIfIcnfIons. IIrsf, In fhIs rofocoI nII frnnsIfIons fo fho
oxcIusIvo sfnfo gonornfo n wrIfo mIss on fho bus, nnd wo nssumo fhnf fho roquosfIng
cncho nIwnys fIIIs fho bIock wIfh fho confonfs rofurnod. ThIs sImIIfIos fho dofnIIod
ImIomonfnfIon. Mosf ronI rofocoIs dIsfInguIsh bofwoon n wrIfo mIss nnd n wrIfo hIf,
whIch cnn occur whon fho cncho bIock Is InIfInIIy In fho shnrod sfnfo.
Computev AvcLItectuve
TLunguveI Muvugun 294
Such mIssos nro cnIIod ounereIip or upgroJe mIssos, sInco fhoy InvoIvo chnngIng
fho sfnfo of fho bIock, buf do nof ncfunIIy roquIro n dnfn fofch. To suorf such sfnfo
chnngos, fho rofocoI usos nn intoliJoIe operoIion, In nddIfIon fo n wrIfo mIss. WIfh
such oornfIons, howovor, fho ncfunI ImIomonfnfIon of fho rofocoI bocomos sIIghfIy
moro comIox.
Tho socond mnjor sImIIfIcnfIon Is fhnf mnny muIfIrocossors dIsfInguIsh
bofwoon n cncho bIock fhnf Is ronIIy shnrod nnd ono fhnf oxIsfs In fho cIonn sfnfo In
oxncfIy ono cncho. ThIs nddIfIon of n cIonn nnd rIvnfo sfnfo oIImInnfos fho nood fo
gonornfo n bus frnnsncfIon on n wrIfo fo such n bIock. Anofhor onhnncomonf In wIdo uso
nIIows ofhor cnchos fo suIy dnfn on n mIss fo n shnrod bIock.

5.4 PRIORMANC OI SYMMTRIC SHAR-MMORY MUITIPROCSSORS
In n bus-bnsod muIfIrocossor usIng nn InvnIIdnfIon rofocoI, sovornI dIfforonf
honomonn combIno fo doformIno orformnnco. In nrfIcuInr, fho ovornII cncho
orformnnco Is n combInnfIon of fho bohnvIor of unIrocossor cncho mIss frnffIc nnd fho
frnffIc cnusod by communIcnfIon, whIch rosuIfs In InvnIIdnfIons nnd subsoquonf cncho
mIssos.
ChnngIng fho rocossor counf, cncho sIzo, nnd bIock sIzo cnn nffocf fhoso fwo
comononfs of fho mIss rnfo In dIfforonf wnys, IondIng fo ovornII sysfom bohnvIor fhnf
Is n combInnfIon of fho fwo offocfs.
Tho mIssos fhnf nrIso from Inforrocossor communIcnfIon, whIch nro offon cnIIod
coIerence nieeee, cnn bo brokon Info fwo sonrnfo sourcos. Tho fIrsf sourco nro fho so-
cnIIod Irue eIoring nieeee fhnf nrIso from fho communIcnfIon of dnfn fhrough fho cncho
cohoronco mochnnIsm.
Tho socond offocf, cnIIod folee eIoring, nrIsos from fho uso of nn InvnIIdnfIon
bnsod cohoronco nIgorIfhm wIfh n sIngIo vnIId bIf or cncho bIock. InIso shnrIng occurs
whon n bIock Is InvnIIdnfod (nnd n subsoquonf roforonco cnusos n mIss) bocnuso somo
word In fho bIock, ofhor fhnn fho ono boIng rond, Is wrIffon Info. Truo shnrIng nnd fnIso
shnrIng mIss rnfos cnn bo nffocfod by n vnrIofy of chnngos In fho cncho nrchIfocfuro.


Computev AvcLItectuve
TLunguveI Muvugun 295
PevIovmunce Meusuvements oI tLe CommevcIuI WovkIoud
Tho AIhnsorvor 4l00 usod for fhoso monsuromonfs hns four rocossors. Inch rocossor
hns n fhroo-IovoI cncho hIornrchy:
!l consIsf of n nIr of 8 KI dIrocf-mnod on-chI cnchos, ono for InsfrucfIon nnd
ono for dnfn. Tho bIock sIzo Is 32-byfos, nnd fho dnfn cncho Is wrIfo-fhrough fo
!2, usIng n wrIfo buffor.
!2 Is n 96 KI on-chI unIfIod 3-wny sof nssocInfIvo cncho wIfh n 32-byfo bIock
sIzo, usIng wrIfo-bnck.
!3 Is nn off-chI, combInod, dIrocf-mnod 2 MI cnchos wIfh 64-byfo bIocks nIso
usIng wrIfo-bnck.

PevIovmunce oI tLe MuItIpvogvummIng und OS WovkIoud
Wo oxnmIno fho cncho orformnnco of fho muIfIrogrnmmod workIond ns fho
cncho sIzo nnd bIock sIzo nro chnngod. Tho workIond romnIns fho snmo.
Two Indoondonf nrnIIoI mnkos, onch usIng u fo oIghf rocossors. Iocnuso of
dIfforoncos bofwoon fho bohnvIor of fho kornoI nnd fhnf of fho usor rocossos, wo koo
fhoso fwo comononfs sonrnfo.

Tho mIssos cnn bo brokon Info fhroo sIgnIfIcnnf cInssos:
ComuIsory, or coId, mIssos rorosonf fho fIrsf nccoss fo fhIs bIocks by fhIs
rocossor nnd nro sIgnIfIcnnf In fhIs workIond.
Cohoronco mIssos rorosonf mIssos duo fo InvnIIdnfIons.
ormnI cnncIfy mIssos IncIudo mIssos cnusod by Inforforonco bofwoon fho OS
nnd fho usor rocoss nnd bofwoon muIfIIo usor rocossos. ConfIIcf mIssos nro
IncIudod In fhIs cnfogory.

Ior fhIs workIond fho bohnvIor of fho oornfIng sysfom Is moro comIox fhnn fho
usor rocossos. ThIs Is for fwo ronsons. IIrsf, fho kornoI InIfInIIzos nII ngos boforo
nIIocnfIng fhom fo n usor, whIch sIgnIfIcnnfIy Incronsos fho comuIsory comononf of
fho kornoI`s mIss rnfo. Socond, fho kornoI ncfunIIy shnros dnfn nnd fhus hns n
nonfrIvInI cohoronco mIss rnfo.
Computev AvcLItectuve
TLunguveI Muvugun 296
IncronsIng fho bIock sIzo Is IIkoIy fo hnvo bonofIcInI offocfs for fhIs workIond,
sInco n Inrgor frncfIon of fho mIssos nrIso from comuIsory nnd cnncIfy, bofh of whIch
cnn bo ofonfInIIy Imrovod wIfh Inrgor bIock sIzos. SInco cohoronco mIssos nro
roInfIvoIy moro rnro, fho nognfIvo offocfs of IncronsIng bIock sIzo shouId bo smnII.
Tho nbsonco of Inrgo Incronsos In fho cohoronco mIss rnfo ns bIock sIzo Is
Incronsod monns fhnf fnIso shnrIng offocfs nro InsIgnIfIcnnf. Ior fho muIfIrogrnmmod
workIond, fho OS Is n much moro domnndIng usor of fho momory sysfom.
If moro OS or OS-IIko ncfIvIfy Is IncIudod In fho workIond, If wIII bocomo vory
dIffIcuIf fo buIId n suffIcIonfIy cnnbIo momory sysfom.

PevIovmunce Iov tLe ScIentIIIc/TecLnIcuI WovkIoud
Wo uso n sImuInfor fo sfudy fho orformnnco of our four scIonfIfIc nrnIIoI rogrnms.
Ior fhoso monsuromonfs, fho robIom sIzos nro ns foIIows:
Bornee-HuIl6K bodIos run for sIx fImo sfos (fho nccurncy confroI Is sof fo l.0,
n fyIcnI, ronIIsfIc vnIuo);
IITl mIIIIon comIox dnfn oInfs
IUA 5l2 5l2 mnfrIx Is usod wIfh l6 l6 bIocks
OceonA l30 l30 grId wIfh n fyIcnI orror foIornnco

In IookIng nf fho mIss rnfos ns wo vnry rocossor counf, cncho sIzo, nnd bIock sIzo,
wo docomoso fho fofnI mIss rnfo Info coIerence nieeee nnd normnI unIrocossor
mIssos.

In IIT, fho cnncIfy mIss rnfo dros (from nonrIy ? fo jusf ovor 5) buf fho
cohoronco mIss rnfo Incronsos (from nbouf l fo nbouf 2.?), IondIng fo n consfnnf
ovornII mIss rnfo.In !!, n vory smnII cncho (nbouf 4 KI) cnn cnfuro fho nIr of l6 l6
bIocks usod In fho Innor Ioo; boyond fhnf fho noxf bIg Imrovomonf In cnncIfy mIss
rnfo occurs whon bofh mnfrIcos fIf In fho cnchos, whIch occurs whon fho fofnI cncho sIzo
Is bofwoon 4 MI nnd 8 MI. ThIs offocf, somofImos cnIIod n uorling eeI effecI, Is nrfIy
nf work bofwoon 32 KI nnd l28 KI for IIT, whoro fho cnncIfy mIss rnfo dros onIy
0.3.
Computev AvcLItectuve
TLunguveI Muvugun 29?
5.5 ISTRIBUT SHAR-MMORY ARCHITCTURS

Thoro nro sovornI dIsndvnnfngos In SymmofrIc Shnrod Momory nrchIfocfuros.
IIrsf, comIIor mochnnIsms for frnnsnronf soffwnro cncho cohoronco nro vory IImIfod.
Socond, wIfhouf cncho cohoronco, fho muIfIrocossor Iosos fho ndvnnfngo of boIng nbIo
fo fofch nnd uso muIfIIo words In n sIngIo cncho bIock for cIoso fo fho cosf of fofchIng
ono word.
ThIrd, mochnnIsms for foIornfIng Infoncy such ns rofofch nro moro usofuI whon
fhoy cnn fofch muIfIIo words, such ns n cncho bIock, nnd whoro fho fofchod dnfn
romnIn cohoronf; wo wIII oxnmIno fhIs ndvnnfngo In moro dofnII Infor. Thoso
dIsndvnnfngos nro mngnIfIod by fho Inrgo Infoncy of nccoss fo romofo momory vorsus n
IocnI cncho. Ior fhoso ronsons, cncho cohoronco Is nn nccofod roquIromonf In smnII-
scnIo muIfIrocossors.
Ior Inrgor-scnIo nrchIfocfuros, fhoro nro now chnIIongos fo oxfondIng fho cncho-
cohoronf shnrod-momory modoI. AIfhough fho bus cnn corfnInIy bo roIncod wIfh n
moro scnInbIo InforconnocfIon nofwork nnd wo couId corfnInIy dIsfrIbufo fho momory so
fhnf fho momory bnndwIdfh couId nIso bo scnIod, fho Inck of scnInbIIIfy of fho snooIng
cohoronco schomo noods fo bo nddrossod Is known ns IsfrIbufod Shnrod Momory
nrchIfocfuro.
Tho fIrsf cohoronco rofocoI Is known ns n dIrocfory rofocoI. A JirecIor, koos
fho sfnfo of ovory bIock fhnf mny bo cnchod. InformnfIon In fho dIrocfory IncIudos whIch
cnchos hnvo coIos of fho bIock, whofhor If Is dIrfy, nnd so on. To rovonf fho dIrocfory
from bocomIng fho boffIonock, dIrocfory onfrIos cnn bo dIsfrIbufod nIong wIfh fho
momory, so fhnf dIfforonf dIrocfory nccossos cnn go fo dIfforonf IocnfIons, jusf ns
dIfforonf momory roquosfs go fo dIfforonf momorIos. A dIsfrIbufod dIrocfory rofnIns fho
chnrncforIsfIc fhnf fho shnrIng sfnfus of n bIock Is nIwnys In n sIngIo known IocnfIon.
ThIs roorfy Is whnf nIIows fho cohoronco rofocoI fo nvoId brondcnsf. IIguro shows
how our dIsfrIbufod-momory muIfIrocossor Iooks wIfh fho dIrocforIos nddod fo onch
nodo.
Computev AvcLItectuve
TLunguveI Muvugun 29B

A dIvectovy Is udded to eucL node to ImpIement cucLe coLevence In u
dIstvIbuted-memovy muItIpvocessov.
Ivectovy-Bused CucLe-CoLevence PvotocoIs: TLe BusIcs
Thoro nro fwo rImnry oornfIons fhnf n dIrocfory rofocoI musf ImIomonf:
hnndIIng n rond mIss nnd hnndIIng n wrIfo fo n shnrod, cIonn cncho bIock. (HnndIIng n
wrIfo mIss fo n shnrod bIock Is n sImIo combInnfIon of fhoso fwo.) To ImIomonf fhoso
oornfIons, n dIrocfory musf frnck fho sfnfo of onch cncho bIock. In n sImIo rofocoI,
fhoso sfnfos couId bo fho foIIowIng:

ShureJOno or moro rocossors hnvo fho bIock cnchod, nnd fho vnIuo In momory Is u
fo dnfo (ns woII ns In nII fho cnchos)
UncucheJo rocossor hns n coy of fho cncho bIock
ErcluoiteIxncfIy ono rocossor hns n coy of fho cncho bIock nnd If hns wrIffon fho
bIock, so fho momory coy Is ouf of dnfo. Tho rocossor Is cnIIod fho ouner of fho bIock.
In nddIfIon fo frnckIng fho sfnfo of onch cncho bIock, wo musf frnck fho
rocossors fhnf hnvo coIos of fho bIock whon If Is shnrod, sInco fhoy wIII nood fo bo
InvnIIdnfod on n wrIfo. Tho sImIosf wny fo do fhIs Is fo koo n bIf vocfor for onch
momory bIock. Whon fho bIock Is shnrod, onch bIf of fho vocfor IndIcnfos whofhor fho
corrosondIng rocossor hns n coy of fhnf bIock.
Computev AvcLItectuve
TLunguveI Muvugun 299
Messuge
type Souvce estInutIon
Messuge
contents IunctIon oI tLIs messuge
!ond mIss !ocnI
cncho
Homo
dIrocfory
I, A Irocossor I hns n rond mIss
nf nddross A; roquosf dnfn
nnd mnko I n rond shnror.
WrIfo
mIss
!ocnI
cncho Homo
dIrocfory
I, A Irocossor I hns n wrIfo
mIss nf nddross A;
roquosf dnfn nnd mnko I
fho oxcIusIvo ownor.
InvnIIdnfo Homo
dIrocfory
!omofo
cncho
A InvnIIdnfo n shnrod coy of
dnfn nf nddross A.



Iofch Homo
dIrocfory
!omofo
cncho
A Iofch fho bIock nf nddross
A nnd sond If fo Ifs homo
dIrocfory; chnngo fho sfnfo
of A In fho romofo cncho fo
shnrod.
Iofch/Invn
IIdnfo
Homo
dIrocfory
!omofo
cncho
A Iofch fho bIock nf nddross
A nnd sond If fo Ifs homo
dIrocfory; InvnIIdnfo fho
bIock In fho cncho.
nfn
vnIuo
roIy
Homo
dIrocfory
!ocnI cncho !ofurn n dnfn vnIuo from
fho homo momory.
nfn wrIfo
bnck
!omofo
cncho
Homo
dIrocfory
A, WrIfo bnck n dnfn vnIuo for
nddross A.
TLe possIbIe messuges sent umong nodes to muIntuIn coLevence uve sLown
wItL tLe souvce und destInutIon node, tLe contents (wLeve P=vequestIng
pvocessov numbev), A=vequested uddvess, und =dutu contents), und tLe
IunctIon oI tLe messuge.
Computev AvcLItectuve
TLunguveI Muvugun 300
Wo cnn nIso uso fho bIf vocfor fo koo frnck of fho ownor of fho bIock whon fho
bIock Is In fho oxcIusIvo sfnfo. Ior offcIoncy ronsons, wo nIso frnck fho sfnfo of onch
cncho bIock nf fho IndIvIdunI cnchos. A cnfnIog of fho mossngo fyos fhnf mny bo sonf
bofwoon fho rocossors nnd fho dIrocforIos. IIguro shows fho fyo of mossngos sonf
nmong nodos.
Tho locol nodo Is fho nodo whoro n roquosf orIgInnfos. Tho Ione nodo Is fho
nodo whoro fho momory IocnfIon nnd fho dIrocfory onfry of nn nddross rosIdo. Tho
hysIcnI nddross snco Is sfnfIcnIIy dIsfrIbufod, so fho nodo fhnf confnIns fho momory
nnd dIrocfory for n gIvon hysIcnI nddross Is known.
Ior oxnmIo, fho hIgh-ordor bIfs mny rovIdo fho nodo numbor, whIIo fho Iow-
ordor bIfs rovIdo fho offsof wIfhIn fho momory on fhnf nodo. Tho IocnI nodo mny nIso
bo fho homo nodo. Tho dIrocfory musf bo nccossod whon fho homo nodo Is fho IocnI
nodo, sInco coIos mny oxIsf In yof n fhIrd nodo, cnIIod n romofo nodo.
A renoIe nodo Is fho nodo fhnf hns n coy of n cncho bIock, whofhor oxcIusIvo (In
whIch cnso If Is fho onIy coy) or shnrod. A romofo nodo mny bo fho snmo ns oIfhor fho
IocnI nodo or fho homo nodo. In such cnsos, fho bnsIc rofocoI doos nof chnngo, buf
Inforrocossor mossngos mny bo roIncod wIfh Infrnrocossor mossngos.

An umpIe Ivectovy PvotocoI
Tho sfnfo frnnsIfIons for nn IndIvIdunI cncho nro cnusod by rond mIssos, wrIfo
mIssos, InvnIIdnfos, nnd dnfn fofch roquosfs. An IndIvIdunI cncho nIso gonornfos rond
nnd wrIfo mIss mossngos fhnf nro sonf fo fho homo dIrocfory. !ond nnd wrIfo mIssos
roquIro dnfn vnIuo roIIos, nnd fhoso ovonfs wnIf for roIIos boforo chnngIng sfnfo.
Tho oornfIon of fho sfnfo frnnsIfIon dIngrnm for n cncho bIock Is ossonfInIIy fho
snmo ns If Is for fho snooIng cnso: fho sfnfos nro IdonfIcnI, nnd fho sfImuIus Is nImosf
IdonfIcnI.
In n dIrocfory-bnsod rofocoI, fho dIrocfory ImIomonfs fho ofhor hnIf of fho
cohoronco rofocoI. A mossngo sonf fo n dIrocfory cnusos fwo dIfforonf fyos of ncfIons:
udnfos of fho dIrocfory sfnfo, nnd sondIng nddIfIonnI mossngos fo snfIsfy fho roquosf.
Computev AvcLItectuve
TLunguveI Muvugun 301

Stute tvunsItIon dIugvum Iov un IndIvIduuI cucLe bIock In u dIvectovy bused
system.

In nddIfIon fo fho sfnfo of onch bIock, fho dIrocfory musf frnck fho sof of rocossors fhnf
hnvo n coy of n bIock; wo uso n sof cnIIod SIorere fo orform fhIs funcfIon. IIguro
shows fho ncfIons fnkon nf fho dIrocfory In rosonso fo mossngos rocoIvod. Tho
dIrocfory rocoIvos fhroo dIfforonf roquosfs: rond mIss, wrIfo mIss, nnd dnfn wrIfo bnck.

Whon n bIock Is In fho uncnchod sfnfo fho coy In momory Is fho curronf vnIuo, so fho
onIy ossIbIo roquosfs for fhnf bIock nro
IeoJ nieeTho roquosfIng rocossor Is sonf fho roquosfod dnfn from momory
nnd fho roquosfor Is mndo fho onIy shnrIng nodo. Tho sfnfo of fho bIock Is mndo
shnrod.
Computev AvcLItectuve
TLunguveI Muvugun 302
WriIe nieeTho roquosfIng rocossor Is sonf fho vnIuo nnd bocomos fho ShnrIng
nodo. Tho bIock Is mndo oxcIusIvo fo IndIcnfo fhnf fho onIy vnIId coy Is cnchod.
Shnrors IndIcnfo fho IdonfIfy of fho ownor.


TLe stute tvunsItIon dIugvum Iov tLe dIvectovy Lus tLe sume stutes und
stvuctuve us tLe tvunsItIon dIugvum Iov un IndIvIduuI cucLe.

Whon fho bIock Is In fho shnrod sfnfo fho momory vnIuo Is u-fo-dnfo, so fho snmo fwo
roquosfs cnn occur:
IeoJ nieeTho roquosfIng rocossor Is sonf fho roquosfod dnfn from momory
nnd fho roquosfIng rocossor Is nddod fo fho shnrIng sof.
WriIe nieeTho roquosfIng rocossor Is sonf fho vnIuo. AII rocossors In fho sof
Shnrors nro sonf InvnIIdnfo mossngos, nnd fho Shnrors sof Is fo confnIn fho
IdonfIfy of fho roquosfIng rocossor. Tho sfnfo of fho bIock Is mndo oxcIusIvo.
Computev AvcLItectuve
TLunguveI Muvugun 303
Whon fho bIock Is In fho oxcIusIvo sfnfo fho curronf vnIuo of fho bIock Is hoId In fho
cncho of fho rocossor IdonfIfIod by fho sof shnrors (fho ownor), so fhoro nro fhroo
ossIbIo dIrocfory roquosfs:
IeoJ nieefho ownor rocossor Is sonf n dnfn fofch mossngo, whIch cnusos fho
sfnfo of fho bIock In fho ownor`s cncho fo frnnsIfIon fo shnrod nnd cnusos fho
ownor fo sond fho dnfn fo fho dIrocfory, whoro If Is wrIffon fo momory nnd sonf
bnck fo fho roquosfIng rocossor. Tho IdonfIfy of fho roquosfIng rocossor Is
nddod fo fho sof shnrors, whIch sfIII confnIns fho IdonfIfy of fho rocossor fhnf
wns fho ownor (sInco If sfIII hns n rondnbIo coy).
DoIo uriIe-IoclTho ownor rocossor Is roIncIng fho bIock nnd fhoroforo musf
wrIfo If bnck. ThIs wrIfo-bnck mnkos fho momory coy u fo dnfo (fho homo
dIrocfory ossonfInIIy bocomos fho ownor), fho bIock Is now uncnchod, nnd fho
shnror sof Is omfy.
WriIe nieeTho bIock hns n now ownor. A mossngo Is sonf fo fho oId ownor
cnusIng fho cncho fo InvnIIdnfo fho bIock nnd sond fho vnIuo fo fho dIrocfory,
from whIch If Is sonf fo fho roquosfIng rocossor, whIch bocomos fho now ownor.
A shnror Is sof fo fho IdonfIfy of fho now ownor, nnd fho sfnfo of fho bIock
romnIns oxcIusIvo.

5.6 PRIORMANC OI ISTRIBUT SHAR-MMORY
MUITIPROCSSORS
Tho orformnnco of n dIrocfory-bnsod muIfIrocossor doonds on mnny of fho
snmo fncfors fhnf InfIuonco fho orformnnco of bus-bnsod muIfIrocossors (o.g., cncho
sIzo, rocossor counf, nnd bIock sIzo), ns woII ns fho dIsfrIbufIon of mIssos fo vnrIous
IocnfIons In fho momory hIornrchy.
In dIsfrIbufod momory nrchIfocfuros, fho dIsfrIbufIon of momory roquosfs
bofwoon IocnI nnd romofo Is koy fo orformnnco, bocnuso If nffocfs bofh fho
consumfIon of gIobnI bnndwIdfh nnd fho Infoncy soon by roquosfs.As IIguro (l) shows,
fho mIss rnfos wIfh fhoso cncho sIzos nro nof nffocfod much by chnngos In rocossor
counf, wIfh fho oxcofIon of Oconn, whoro fho mIss rnfo rIsos nf 64 rocossors.
Computev AvcLItectuve
TLunguveI Muvugun 304
ThIs rIso rosuIfs from fwo fncfors: nn Incronso In mnIng confIIcfs In fho cncho
fhnf occur whon fho grId bocomos smnII, whIch Ionds fo n rIso In IocnI mIssos, nnd nn
Incronso In fho numbor of fho cohoronco mIssos, whIch nro nII romofo.
IIguro (2) shows how fho mIss rnfos chnngo ns fho cncho sIzo Is Incronsod,
nssumIng n 64-rocossor oxocufIon nnd 64-byfo bIocks. Thoso mIss rnfos docronso nf
rnfos fhnf wo mIghf oxocf, nIfhough fho dnmonIng offocf cnusod by IIffIo or no
roducfIon In cohoronco mIssos Ionds fo n sIowor docronso In fho romofo mIssos fhnn In
fho IocnI mIssos. Iy fho fImo wo ronch fho Inrgosf cncho sIzo shown, 5l2 KI, fho romofo
mIss rnfo Is oqunI fo or gronfor fhnn fho IocnI mIss rnfo. !nrgor cnchos wouId nmIIfy
fhIs frond.



(1) TLe dutu mIss vute Is oIten steudy us pvocessovs uve udded Iov tLese
bencLmuvks.
Computev AvcLItectuve
TLunguveI Muvugun 305

(2)MIss vutes decveuse us cucLe sIzes gvow.

5.? SYNCHRONIZATION
SynchronIznfIon mochnnIsms nro fyIcnIIy buIIf wIfh usor-IovoI soffwnro
roufInos fhnf roIy on hnrdwnro-suIIod synchronIznfIon InsfrucfIons. Tho offIcIonf sIn
Iocks cnn bo buIIf usIng n sImIo hnrdwnro synchronIznfIon InsfrucfIon nnd fho
cohoronco mochnnIsm.
BusIc Huvdwuve PvImItIves
Tho koy nbIIIfy wo roquIro fo ImIomonf synchronIznfIon In n muIfIrocossor Is n
sof of hnrdwnro rImIfIvos wIfh fho nbIIIfy fo nfomIcnIIy rond nnd modIfy n momory
IocnfIon. WIfhouf such n cnnbIIIfy, fho cosf of buIIdIng bnsIc synchronIznfIon
rImIfIvos wIII bo foo hIgh nnd wIII Incronso ns fho rocossor counf Incronsos.
Thoro nro n numbor of nIfornnfIvo formuInfIons of fho bnsIc hnrdwnro rImIfIvos,
nII of whIch rovIdo fho nbIIIfy fo nfomIcnIIy rond nnd modIfy n IocnfIon, fogofhor wIfh
somo wny fo foII If fho rond nnd wrIfo woro orformod nfomIcnIIy. Thoso hnrdwnro
rImIfIvos nro fho bnsIc buIIdIng bIocks fhnf nro usod fo buIId n wIdo vnrIofy of usor-
IovoI synchronIznfIon oornfIons, IncIudIng fhIngs such ns Iocks nnd bnrrIors.
Computev AvcLItectuve
TLunguveI Muvugun 306
Ono fyIcnI oornfIon for buIIdIng synchronIznfIon oornfIons Is fho oIonic
excIongo, whIch Inforchnngos n vnIuo In n rogIsfor for n vnIuo In momory. !so fhIs fo
buIId n bnsIc synchronIznfIon oornfIon, nssumo fhnf wo wnnf fo buIId n sImIo Iock
whoro fho vnIuo 0 Is usod fo IndIcnfo fhnf fho Iock Is froo nnd n l Is usod fo IndIcnfo fhnf
fho Iock Is unnvnIInbIo.
A rocossor frIos fo sof fho Iock by doIng nn oxchnngo of l, whIch Is In n rogIsfor,
wIfh fho momory nddross corrosondIng fo fho Iock. Tho vnIuo rofurnod from fho
oxchnngo InsfrucfIon Is l If somo ofhor rocossor hnd nIrondy cInImod nccoss nnd 0
ofhorwIso. In fho Inffor cnso, fho vnIuo Is nIso chnngod fo bo l, rovonfIng nny
comofIng oxchnngo from nIso rofrIovIng n 0.
Thoro nro n numbor of ofhor nfomIc rImIfIvos fhnf cnn bo usod fo ImIomonf
synchronIznfIon. Thoy nII hnvo fho koy roorfy fhnf fhoy rond nnd udnfo n momory
vnIuo In such n mnnnor fhnf wo cnn foII whofhor or nof fho fwo oornfIons oxocufod
nfomIcnIIy.
Ono oornfIon, rosonf In mnny oIdor muIfIrocossors, Is IeeI-onJ-eeI, whIch
fosfs n vnIuo nnd sofs If If fho vnIuo nssos fho fosf. Ior oxnmIo, wo couId dofno nn
oornfIon fhnf fosfod for 0 nnd sof fho vnIuo fo l, whIch cnn bo usod In n fnshIon sImIInr
fo how wo usod nfomIc oxchnngo.
Anofhor nfomIc synchronIznfIon rImIfIvo Is feIcI-onJ-increnenI. If rofurns fho
vnIuo of n momory IocnfIon nnd nfomIcnIIy Incromonfs If. Iy usIng fho vnIuo 0 fo
IndIcnfo fhnf fho synchronIznfIon vnrInbIo Is uncInImod, wo cnn uso fofch-nnd-
Incromonf, jusf ns wo usod oxchnngo. Thoro nro ofhor usos of oornfIons IIko fofch-nnd-
Incromonf.

ImpIementIng Iocks UsIng CoLevence
Wo cnn uso fho cohoronco mochnnIsms of n muIfIrocossor fo ImIomonf epin
locle. Iocks fhnf n rocossor confInuousIy frIos fo ncquIro, sInnIng nround n Ioo unfII
If succoods. SIn Iocks nro usod whon n rogrnmmor oxocfs fho Iock fo bo hoId for n
vory shorf nmounf of fImo nnd whon sho wnnfs fho rocoss of IockIng fo bo Iow Infoncy
whon fho Iock Is nvnIInbIo.
Computev AvcLItectuve
TLunguveI Muvugun 30?
Iocnuso sIn Iocks fIo u fho rocossor, wnIfIng In n Ioo for fho Iock fo bocomo
froo, fhoy nro InnrorInfo In somo cIrcumsfnncos. Tho sImIosf ImIomonfnfIon,
whIch wo wouId uso If fhoro woro no cncho cohoronco, wouId koo fho Iock vnrInbIos In
momory. A rocossor couId confInunIIy fry fo ncquIro fho Iock usIng nn nfomIc
oornfIon, sny oxchnngo, nnd fosf whofhor fho oxchnngo rofurnod fho Iock ns froo. To
roIonso fho Iock, fho rocossor sImIy sforos fho vnIuo 0 fo fho Iock. Horo Is fho codo
soquonco fo Iock n sIn Iock whoso nddross Is In !l usIng nn nfomIc oxchnngo:
A!I !2,!0,#l
IockIf: IXCH !2,0(!l) ; nfomIc oxchnngo
IIZ !2,IockIf ; nIrondy Iockod`

If our muIfIrocossor suorfs cncho cohoronco, wo cnn cncho fho Iocks usIng fho
cohoronco mochnnIsm fo mnInfnIn fho Iock vnIuo cohoronfIy. CnchIng Iocks hns fwo
ndvnnfngos. IIrsf, If nIIows nn ImIomonfnfIon whoro fho rocoss of sInnIng (fryIng
fo fosf nnd ncquIro fho Iock In n fIghf Ioo) couId bo dono on n IocnI cnchod coy rnfhor
fhnn roquIrIng n gIobnI momory nccoss on onch nffomf fo ncquIro fho Iock.
Tho socond ndvnnfngo comos from fho obsorvnfIon fhnf fhoro Is offon IocnIIfy In
Iock nccossos: fhnf Is, fho rocossor fhnf usod fho Iock Insf wIII uso If ngnIn In fho nonr
fufuro. In such cnsos, fho Iock vnIuo mny rosIdo In fho cncho of fhnf rocossor, gronfIy
roducIng fho fImo fo ncquIro fho Iock.

SyncLvonIzutIon PevIovmunce CLuIIenges
BuvvIev SyncLvonIzutIon
Ono nddIfIonnI common synchronIznfIon oornfIon In rogrnms wIfh nrnIIoI
Ioos Is n Iorrier. A bnrrIor forcos nII rocossos fo wnIf unfII nII fho rocossos ronch fho
bnrrIor nnd fhon roIonsos nII of fho rocossos. A fyIcnI ImIomonfnfIon of n bnrrIor cnn
bo dono wIfh fwo sIn Iocks: ono usod fo rofocf n counfor fhnf fnIIIos fho rocossos
nrrIvIng nf fho bnrrIor nnd ono usod fo hoId fho rocossos unfII fho Insf rocoss nrrIvos
nf fho bnrrIor.
Computev AvcLItectuve
TLunguveI Muvugun 30B
SyncLvonIzutIon MecLunIsms Iov Iuvgev-ScuIe MuItIpvocessovs
SoItwuve ImpIementutIons
Tho mnjor dIffIcuIfy wIfh our sIn-Iock ImIomonfnfIon Is fho doIny duo fo
confonfIon whon mnny rocossos nro sInnIng on fho Iock. Ono soIufIon Is fo nrfIfIcInIIy
doIny rocossos whon fhoy fnII fo ncquIro fho Iock. Tho bosf orformnnco Is obfnInod by
IncronsIng fho doIny oxononfInIIy whonovor fho nffomf fo ncquIro fho Iock fnIIs.
IIguro shows how n sIn Iock wIfh exponenIiol Iocl-off Is ImIomonfod.
IxononfInI bnck-off Is n common fochnIquo for roducIng confonfIon In shnrod
rosourcos, IncIudIng nccoss fo shnrod nofworks nnd busos. ThIs ImIomonfnfIon sfIII
nffomfs fo rosorvo Iow Infoncy whon confonfIon Is smnII by nof doInyIng fho InIfInI
sIn Ioo.
Tho rosuIf Is fhnf If mnny rocossos nro wnIfIng, fho bnck-off doos nof nffocf fho
rocossos on fhoIr fIrsf nffomf fo ncquIro fho Iock. Wo couId nIso doIny fhnf rocoss,
buf fho rosuIf wouId bo ooror orformnnco whon fho Iock wns In uso by onIy fwo
rocossos nnd fho fIrsf ono hnonod fo fInd If Iockod.

A!I !3,!0,#l ;!3 = InIfInI doIny
IockIf: !! !2,0(!l) ;Iond IInkod
IIZ !2,IockIf ;nof nvnIInbIo-sIn
A!I
!2,!2,#l
;gof Iockod vnIuo
SC !2,0(!l) ;sforo condIfIonnI
IIZ !2,gofIf ;brnnch If sforo succoods
S!! !3,!3,#l ;Incronso doIny by fncfor of 2
IA!SI !3 ;doInys by vnIuo In !3
J IockIf
gofIf:
uso dnfn rofocfod by Iock

A spIn Iock wItL eponentIuI buck-oII.

Computev AvcLItectuve
TLunguveI Muvugun 309
Anofhor fochnIquo for ImIomonfIng Iocks Is fo uso quouIng Iocks. QuouIng Iocks
work by consfrucfIng n quouo of wnIfIng rocossors; whonovor n rocossor froos u fho
Iock, If cnusos fho noxf rocossor In fho quouo fo nffomf nccoss. ThIs oIImInnfos
confonfIon for n Iock whon If Is frood. Wo show how quouIng Iocks oornfo In fho noxf
socfIon usIng n hnrdwnro ImIomonfnfIon, buf soffwnro ImIomonfnfIons usIng nrrnys
cnn nchIovo mosf of fho snmo bonofIfs Ioforo wo Iook nf hnrdwnro rImIfIvos,
Huvdwuve PvImItIves
In fhIs socfIon wo Iook nf fwo hnrdwnro synchronIznfIon rImIfIvos. Tho fIrsf
rImIfIvo donIs wIfh Iocks, whIIo fho socond Is usofuI for bnrrIors nnd n numbor of ofhor
usor-IovoI oornfIons fhnf roquIro counfIng or suIyIng dIsfIncf IndIcos.
In bofh cnsos wo cnn cronfo n hnrdwnro rImIfIvo whoro Infoncy Is ossonfInIIy
IdonfIcnI fo our onrIIor vorsIon, buf wIfh much Ioss sorInIIznfIon, IondIng fo boffor
scnIIng whon fhoro Is confonfIon.
Tho mnjor robIom wIfh our orIgInnI Iock ImIomonfnfIon Is fhnf If Infroducos n
Inrgo nmounf of unnoodod confonfIon. Ior oxnmIo, whon fho Iock Is roIonsod nII
rocossors gonornfo bofh n rond nnd n wrIfo mIss, nIfhough nf mosf ono rocossor cnn
succossfuIIy gof fho Iock In fho unIockod sfnfo. ThIs soquonco hnons on onch of fho 20
Iock/unIock soquoncos.
Wo cnn Imrovo fhIs sIfunfIon by oxIIcIfIy hnndIng fho Iock from ono wnIfIng
rocossor fo fho noxf. !nfhor fhnn sImIy nIIowIng nII rocossors fo comofo ovory fImo
fho Iock Is roIonsod, wo koo n IIsf of fho wnIfIng rocossors nnd hnnd fho Iock fo ono
oxIIcIfIy, whon Ifs furn comos. ThIs sorf of mochnnIsm hns boon cnIIod n queuing locl.
QuouIng Iocks cnn bo ImIomonfod oIfhor In hnrdwnro, or In soffwnro usIng nn nrrny fo
koo frnck of fho wnIfIng rocossos.
5.B MOIS OI MMORY CONSISTNCY: AN INTROUCTION
Cncho cohoronco onsuros fhnf muIfIIo rocossors soo n consIsfonf vIow of
momory. If doos nof nnswor fho quosfIon of Iou consIsfonf fho vIow of momory musf bo.
Tho mosf sfrnIghfforwnrd modoI for momory consIsfoncy Is cnIIod eequenIiol
coneieIenc,.
Computev AvcLItectuve
TLunguveI Muvugun 310
SoquonfInI consIsfoncy roquIros fhnf fho rosuIf of nny oxocufIon bo fho snmo ns If
fho momory nccossos oxocufod by onch rocossor woro kof In ordor nnd fho nccossos
nmong dIfforonf rocossors woro nrbIfrnrIIy InforIonvod. SoquonfInI consIsfoncy
oIImInnfos fho ossIbIIIfy of somo nonobvIous oxocufIon In fho rovIous oxnmIo,
bocnuso fho nssIgnmonfs musf bo comIofod boforo fho If sfnfomonfs nro InIfInfod.
Tho sImIosf wny fo ImIomonf soquonfInI consIsfoncy Is fo roquIro n rocossor
fo doIny fho comIofIon of nny momory nccoss unfII nII fho InvnIIdnfIons cnusod by fhnf
nccoss nro comIofod. Of courso, If Is oqunIIy offocfIvo fo doIny fho noxf momory nccoss
unfII fho rovIous ono Is comIofod. !omombor fhnf momory consIsfoncy InvoIvos
oornfIons nmong dIfforonf vnrInbIos: fho fwo nccossos fhnf musf bo ordorod nro
ncfunIIy fo dIfforonf momory IocnfIons.
To rovIdo boffor orformnnco, rosonrchors nnd nrchIfocfs hnvo oxIorod fwo dIfforonf
roufos.
IIrsf, fhoy dovoIood nmbIfIous ImIomonfnfIons fhnf rosorvo soquonfInI
consIsfoncy buf uso Infoncy hIdIng fochnIquos fo roduco fho onnIfy.
Socond, fhoy dovoIood Ioss rosfrIcfIvo momory consIsfoncy modoIs fhnf nIIow for
fnsfor hnrdwnro.

TLe Pvogvummev's VIew
AIfhough fho soquonfInI consIsfoncy modoI hns n orformnnco dIsndvnnfngo,
from fho vIowoInf of fho rogrnmmor If hns fho ndvnnfngo of sImIIcIfy. Tho chnIIongo
Is fo dovoIo n rogrnmmIng modoI fhnf Is sImIo fo oxInIn nnd yof nIIows n hIgh
orformnnco ImIomonfnfIon.
Ono such rogrnmmIng modoI fhnf nIIows us fo hnvo n moro offIcIonf
ImIomonfnfIon Is fo nssumo fhnf rogrnms nro e,ncIroniceJ. A rogrnm Is
synchronIzod If nII nccoss fo shnrod dnfn Is ordorod by synchronIznfIon oornfIons.
A dnfn roforonco Is ordorod by n synchronIznfIon oornfIon If, In ovory ossIbIo
oxocufIon, n wrIfo of n vnrInbIo by ono rocossor nnd nn nccoss (oIfhor n rond or n wrIfo)
of fhnf vnrInbIo by nnofhor rocossor nro sonrnfod by n nIr of synchronIznfIon
oornfIons, ono oxocufod nffor fho wrIfo by fho wrIfIng rocossor nnd ono oxocufod
boforo fho nccoss by fho socond rocossor.
Computev AvcLItectuve
TLunguveI Muvugun 311
Cnsos whoro vnrInbIos mny bo udnfod wIfhouf ordorIng by synchronIznfIon nro
cnIIod JoIo rocee, bocnuso fho oxocufIon oufcomo doonds on fho roInfIvo sood of fho
rocossors, nnd IIko rncos In hnrdwnro dosIgn, fho oufcomo Is unrodIcfnbIo, whIch
Ionds fo nnofhor nnmo for synchronIzod rogrnms: JoIo-roce-free.

ReIued ConsIstency ModeIs: TLe BusIcs
Tho koy Idon In roInxod consIsfoncy modoIs Is fo nIIow ronds nnd wrIfos fo
comIofo ouf of ordor, buf fo uso synchronIznfIon oornfIons fo onforco ordorIng, so fhnf
n synchronIzod rogrnm bohnvos ns If fho rocossor woro soquonfInIIy consIsfonf.
Tho fhroo mnjor sofs of ordorIngs fhnf nro roInxod nro:
Tho W-->R ovdevIng: ThIs yIoIds n modoI known ns fofnI sforo ordorIng or
rocossor consIsfoncy. Iocnuso fhIs ordorIng rofnIns ordorIng nmong wrIfos,
mnny rogrnms fhnf oornfo undor soquonfInI consIsfoncy oornfo undor fhIs
modoI, wIfhouf nddIfIonnI synchronIznfIon.
Tho W-->W ovdevIng: ThIs yIoIds n modoI known ns nrfInI sforo ordor.
Tho R-->W und R-->R ovdevIngs: ThIs yIoIds n vnrIofy of modoIs IncIudIng
wonk ordorIng, fho AIhn consIsfoncy modoI, fho IoworIC consIsfoncy modoI,
nnd roIonso consIsfoncy doondIng on fho dofnIIs of fho ordorIng rosfrIcfIons nnd
how synchronIznfIon oornfIons onforco ordorIng.

IInuI Remuvks on ConsIstency ModeIs
Af fho rosonf fImo, mnny muIfIrocossors boIng buIIf suorf somo sorf of
roInxod consIsfoncy modoI, vnryIng from rocossor consIsfoncy fo roIonso consIsfoncy.
SInco synchronIznfIon Is hIghIy muIfIrocossor socIfIc nnd orror rono, fho
oxocfnfIon Is fhnf mosf rogrnmmors wIII uso sfnndnrd synchronIznfIon IIbrnrIos nnd
wIII wrIfo synchronIzod rogrnms, mnkIng fho choIco of n wonk consIsfoncy modoI
InvIsIbIo fo fho rogrnmmor nnd yIoIdIng hIghor orformnnco.A koy nrf of fhIs
nrgumonf In fnvor of roInxod consIsfoncy rovoIvos fho roIo of fho comIIor nnd Ifs nbIIIfy
fo ofImIzo momory nccoss fo ofonfInIIy shnrod vnrInbIos.


Computev AvcLItectuve
TLunguveI Muvugun 312
5.9 MUITITHRAING: XPIOITING THRA-IVI PARAIIIISM
WITHIN A PROCSSOR
MulIiIIreoJing nIIows muIfIIo fhronds fo shnro fho funcfIonnI unIfs of n sIngIo
rocossor In nn ovorInIng fnshIon. To ormIf fhIs shnrIng, fho rocossor musf
duIIcnfo fho Indoondonf sfnfo of onch fhrond. Ior oxnmIo, n sonrnfo coy of fho
rogIsfor fIIo, n sonrnfo IC, nnd n sonrnfo ngo fnbIo nro roquIrod for onch fhrond.

Thoro nro fwo mnIn nronchos fo muIfIfhrondIng.
Fine-gruineJ multithreuJing swIfchos bofwoon fhronds on onch InsfrucfIon,
cnusIng fho oxocufIon of muIfIIos fhronds fo bo InforIonvod. ThIs InforIonvIng Is offon
dono In n round-robIn fnshIon, skIIng nny fhronds fhnf nro sfnIIod nf fhnf fImo.
Couvse-gvuIned muItItLveudIng wns Invonfod ns nn nIfornnfIvo fo fIno-
grnInod muIfIfhrondIng. Conrso-grnInod muIfIfhrondIng swIfchos fhronds onIy on cosfIy
sfnIIs, such ns IovoI fwo cncho mIssos. ThIs chnngo roIIovos fho nood fo hnvo fhrond-
swIfchIng bo ossonfInIIy froo nnd Is much Ioss IIkoIy fo sIow fho rocossor down, sInco
InsfrucfIons from ofhor fhronds wIII onIy bo Issuod, whon n fhrond oncounfors n cosfIy
sfnII.

SImuItuneous MuItItLveudIng: ConvevtIng TLveud-IeveI PuvuIIeIIsm Into
InstvuctIon-IeveI PuvuIIeIIsm:
SImuIfnnoous muIfIfhrondIng (SMT) Is n vnrInfIon on muIfIfhrondIng fhnf usos
fho rosourcos of n muIfIIo Issuo, dynnmIcnIIy-schoduIod rocossor fo oxIoIf T!I nf fho
snmo fImo If oxIoIfs I!I. Tho koy InsIghf fhnf mofIvnfos SMT Is fhnf modorn muIfIIo-
Issuo rocossors offon hnvo moro funcfIonnI unIf nrnIIoIIsm nvnIInbIo fhnn n sIngIo
fhrond cnn offocfIvoIy uso.
Iurfhormoro, wIfh rogIsfor ronnmIng nnd dynnmIc schoduIIng, muIfIIo
InsfrucfIons from Indoondonf fhronds cnn bo Issuod wIfhouf rognrd fo fho doondoncos
nmong fhom; fho rosoIufIon of fho doondoncos cnn bo hnndIod by fho dynnmIc
schoduIIng cnnbIIIfy.

Computev AvcLItectuve
TLunguveI Muvugun 313
IIguro concofunIIy IIIusfrnfos fho dIfforoncos In n rocossor`s nbIIIfy fo oxIoIf
fho rosourcos of n suorscnInr for fho foIIowIng rocossor confIgurnfIons:
n suorscnInr wIfh no muIfIfhrondIng suorf,
n suorscnInr wIfh conrso-grnInod muIfIfhrondIng,
n suorscnInr wIfh fIno-grnInod muIfIfhrondIng, nnd
n suorscnInr wIfh sImuIfnnoous muIfIfhrondIng.
In fho suorscnInr wIfhouf muIfIfhrondIng suorf, fho uso of Issuo sIofs Is
IImIfod by n Inck of I!I. In fho conrso-grnInod muIfIfhrondod suorscnInr, fho Iong
sfnIIs nro nrfInIIy hIddon by swIfchIng fo nnofhor fhrond fhnf usos fho rosourcos of fho
rocossor. In fho fno-grnInod cnso, fho InforIonvIng of fhronds oIImInnfos fuIIy omfy
sIofs.

TLIs IIIustvutIon sLows Low tLese Iouv dIIIevent uppvoucLes use tLe Issue
sIots oI u supevscuIuv pvocessov.
Iocnuso onIy ono fhrond Issuos InsfrucfIons In n gIvon cIock cycIo.In fho SMT
cnso, fhrond-IovoI nrnIIoIIsm (T!I) nnd InsfrucfIon-IovoI nrnIIoIIsm (I!I) nro
oxIoIfod sImuIfnnoousIy; wIfh muIfIIo fhronds usIng fho Issuo sIofs In n sIngIo cIock
cycIo. IIguro gronfIy sImIIfIos fho ronI oornfIon of fhoso rocossors If doos IIIusfrnfo
fho ofonfInI orformnnco ndvnnfngos of muIfIfhrondIng In gonornI nnd SMT In
nrfIcuInr.
Computev AvcLItectuve
TLunguveI Muvugun 314
esIgn CLuIIenges In SMT pvocessovs
Thoro nro n vnrIofy of dosIgn chnIIongos for nn SMT rocossor, IncIudIng:
onIIng wIfh n Inrgor rogIsfor fIIo noodod fo hoId muIfIIo confoxfs,
MnInfnInIng Iow ovorhond on fho cIock cycIo, nrfIcuInrIy In crIfIcnI sfos such
ns InsfrucfIon Issuo, whoro moro cnndIdnfo InsfrucfIons nood fo bo consIdorod,
nnd In InsfrucfIon comIofIon, whoro choosIng whnf InsfrucfIons fo commIf
mny bo chnIIongIng, nnd
InsurIng fhnf fho cncho confIIcfs gonornfod by fho sImuIfnnoous oxocufIon of
muIfIIo fhronds do nof cnuso sIgnIfIcnnf orformnnco dogrndnfIon.

In vIowIng fhoso robIoms, fwo obsorvnfIons nro Imorfnnf. In mnny cnsos, fho
ofonfInI orformnnco ovorhond duo fo muIfIfhrondIng Is smnII, nnd sImIo choIcos
work woII onough. Socond, fho offIcIoncy of curronf suor-scnInrs Is Iow onough fhnf
fhoro Is room for sIgnIfIcnnf Imrovomonf, ovon nf fho cosf of somo ovorhond.

******N******

Vous aimerez peut-être aussi