0% found this document useful (0 votes)
51 views

Demandpagi NG: Basi Cconcept S

The document discusses demand paging in operating systems. Some key points: - With demand paging, process pages are not all loaded into memory at once when the process is swapped in. Instead, pages are only loaded when needed by the process. - When a process attempts to access a page not currently in memory, a page fault occurs. This triggers steps to locate a free frame, load the needed page from disk, update the page table, and restart the faulting instruction. - In an extreme case, no pages may be swapped in until a page fault requests them. This is known as pure demand paging.

Uploaded by

Yamani Dinakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Demandpagi NG: Basi Cconcept S

The document discusses demand paging in operating systems. Some key points: - With demand paging, process pages are not all loaded into memory at once when the process is swapped in. Instead, pages are only loaded when needed by the process. - When a process attempts to access a page not currently in memory, a page fault occurs. This triggers steps to locate a free frame, load the needed page from disk, update the page table, and restart the faulting instruction. - In an extreme case, no pages may be swapped in until a page fault requests them. This is known as pure demand paging.

Uploaded by

Yamani Dinakar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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