Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

DEMANDPAGI

NG
 Thebasi
cideabehi
nd demandpaging isthatwhenapr ocessis
swappedi
n,it
spagesar enotswappedinal latonce.Rathertheyare
swappedi
nonlywhent heprocessneedst hem.(ondemand.)Thi s
i
stermeda l
azyswapper,al
thougha pager i
samor eaccurat
et er
m.

TRANSFEROFAPAGED MEMORYTOCONTI
GUOUS DI
SKSPACE

Basi
cConcept
s

 Thebasicideabehi ndpagi ngisthatwhenapr ocessis


swappedin,thepageronl yloadsintomemor yt hosepagesthat
i
texpectsthepr ocesst oneed( r
ightaway . 
)
 Pagesthatarenotl oadedi ntomemor yaremar kedasinvali
din
thepagetable,usingt heinvali
dbit.( 
Ther estoft hepagetable
entr
ymayei therbebl ankorcont aininformationaboutwher e
tofi
ndtheswapped- outpageont hehar ddrive. )
 Ift
heprocessonl yev eraccessespagest hatar eloadedin
memor y(memor
  yresi dent 
pages ),
thent hepr ocessruns
exact
lyasi
fal
lthepageswer
eloadedi
ntomemor
y.

PAGETABLEWHENSOMEPAGESARENOTI
NMAI
NMEMORY

 Ont
heot
herhand,
ifapagei
sneededt
hatwasnotor
igi
nal
l
yloadedup,
t page
hena 
f
aul
ttr
ap 
i
sgener
ated,
whi
chmustbehandl
edi
naser
iesofst
eps:

1.Thememoryaddressr
equest
edi
sfi
rstchecked,
tomakesur
eitwasav
ali
d
memoryr
equest.

2.I
ftheref
erencewasi
nval
i
d,t
hepr
ocessi
ster
minat
ed.Ot
her
wise,
thepage
mustbepagedin.

3.Af
reef
ramei
slocat
ed,
possi
blyf
rom af
ree-
fr
amel
i
st.

4.Adiskoperat
ionisscheduledt
obr
ingint
henecessar
ypagef
rom di
sk.(Thi
s
wil
lusual
l
yblockt hepr
ocessonanI/Owait
,al
l
owingsomeotherpr
ocessto
usetheCPUint hemeantime.)

5.WhentheI/Ooper
ationiscompl
ete,
theprocess'
spaget
abl
eisupdat
edwith
thenewfr
amenumber ,
andthei
nval
idbi
tischangedtoi
ndi
cat
ethatt
hisi
s
nowav al
i
dpagereference.

6.Thei
nst
ruct
iont
hatcausedt
hepagef
aul
tmustnowber
est
art
edf
rom t
he
begi
nni
ng,
(assoonast
hispr
ocessget
sanot
hert
urnont
heCPU.)

STEPSI
NHANDLI
NGAPAGEFAULT

 I
nanext
remecase,
NOpagesar
eswappedi
nforapr
ocessunt
ilt
heyar
erequest
ed
bypagef
aul
ts.Thi
si pur
sknownas  edemandpagi
ng.

 I
ntheor
yeachi
nst
ruct
ioncoul
dgener
atemul
ti
plepagef
aul
ts.I
npr
act
icet
hisi
sver
y
r
are,
duet
o l
ocal
i
tyofr
efer
ence,
cov
eredi
nsect
ion9.
6.1.

 Thehar
dwar
enecessar
ytosuppor
tvi
rt
ual
memor
yist
hesameasf
orpagi
ngand
swappi
ng:Apaget
ableandsecondar
ymemor
y.(
 Swapspace,
 
whoseal
l
ocat
ioni
s
di
scussedi
nchapt
er12.
 )
 Acr
uci
alpar
toft
hepr
ocessi
sthatt
hei
nst
ruct
ionmustber
est
art
edf
rom scr
atch
oncet hedesiredpagehasbeenmadeav ai
lableinmemor y
.Formostsimpl e
i
nstructionsthisisnotamaj ordi
ffi
cul
ty.Howev ertherearesomear chi
tecturesthat
all
owasi ngl
einst r
ucti
ontomodifyafairl
ylargeblockofdat a,
( whi
chmayspana
pageboundar y 
),andifsomeofthedataget smodi fi
edbeforethepagef aultoccurs,
thi
scoul dcausepr oblems.Onesoluti
onistoaccessbot hendsoftheblockbef ore
executingtheinstructi
on,guar
anteei
ngthatthenecessar ypagesgetpagedi nbefore
theinstructi
onbegi ns.

You might also like