Beruflich Dokumente
Kultur Dokumente
Chapter 2
TYPES OF MEMORY ALLOCATION SCHEMES: Single-User System fi e! "artiti#ns$ %ynami& "artiti#ns an! Rel#&ata'le %ynami& "artiti#ns(
Algorithm to Load a Jo i! a Si!gl"-U#"r S$#t"m% /( 2( 0( 1( 3( 6( 6( 8( 9( :( St#re first mem#ry all#&ati#n #f pr#gram int# 'ase register( Set pr#gram &#+nter( Rea! first instr+&ti#n #f the pr#gram( 2n&rement pr#gram &#+nter 'y n+m'er #f 'ytes in instr+&ti#n( 4as the last instr+&ti#n 'een rea&he!5 2f yes$ then st#p l#a!ing pr#gram( 2f N#$ then &#ntin+e )ith step 6( 2s pr#gram &#+nter greater than mem#ry si7e5 2f yes$ then st#p l#a!ing pr#gram( 2f N#$ then &#ntin+e )ith step 8( L#a! instr+&ti#n in mem#ry( Rea! ne t instr+&ti#n #f pr#gram( G# t# step 1(
>Mem#ry is the primary an! f+n!amental p#)er$ )ith#+t )hi&h there &#+l! 'e n# #ther intelle&t+al #perati#n(? =Sam+el @#hns#n ;/8A:-/891<
"age /
Chapter 2
A &riti&al fa&t#r )as intr#!+&e! )ith this s&heme: pr#te&ti#n #f the -#'Bs mem#ry spa&e( On&e a partiti#n )as assigne! t# a -#'$ n# #ther -#' &#+l! 'e all#)e! t# enter its '#+n!aries$ either a&&i!entally #r intenti#nally(
2(
2f -#'Csi7e D si7e #f largest partiti#n Then re-e&t the -#' print appr#priate message t# #perat#r g# t# step / t# han!le ne t -#' in line Else &#ntin+e )ith step 0(
2f -#'Csi7e D mem#ryCpartiti#nCsi7e;&#+nter< Then &#+nter F &#+nter G / Else if mem#ryCpartiti#nCsi7e;&#+nter< F >free? Then l#a! -#' int# mem#ryCpartiti#n;&#+nter< &hange mem#ryCpartiti#nCstat+s;&#+nter<t# >'+sy? g# t# step / t# han!le ne t -#' in line Else &#+nter F &#+nter G / En! !# 3 ( N# partiti#n a,aila'le at this time$ p+t -#' in )aiting .+e+e( 6( G# t# step / t# han!le ne t -#' in line(
mem#ry &reates +n+sa'le fragments #f free mem#ry 'et)een 'l#&*s #f '+sy$ #r all#&ate!$ mem#ry( I ter a! fra"me tatio the remaining spa&e 'et)een the partiti#ns is +na,aila'le t# any #ther -#' an! is theref#re )aste!(
Chapter 2
Fir#t-Fit Algorithm
/( Set &#+nter t# /( 2( %# )hile &#+nter EF n+m'er #f 'l#&*s in mem#ry( if -#'Csi7e D mem#ryCsi7e;&#+nter< Then &#+nter F &#+nter G / Else l#a! -#' int# mem#ryCsi7e;&#+nter< a!-+st freeJ'+sy mem#ry lists g# t# step 1 En! !# 0( "+t -#' in )aiting .+e+e( 1( G# fet&h ne t -#'(
("#t-Fit Algorithm
/( 2( 0( 1( 3( 2nitiali7e mem#ryC'l#&*;#< F ::::: C#mp+te initialCmem#ryC'l#&*;#<--#'Csi7e 2ntiali7e s+'s&riptF# Set &#+nter t# / %# )hile &#+nter EF n+m'er #f 'l#&*s in mem#ry if -#'Csi7e D mem#ry si7e ;&#+nter< Then &#+nter F &#+nter G/ Else mem#ryC)aste F mem#ryCsi7e ;&#+nter<--#'Csi7e 2f initialCmem#ryC)aste D mem#ryC)aste Then s+'s&ript F &#+nter 2nitialCmem#ryC)asteFmem#ryC)aste C#+nterF &#+nter G / En! !# 6( 2f s+'s&ript F # Then p+t -#' in )aiting .+e+e Else L#a! -#' int# mem#ryCsi7e ; s+'s&ript< A!-+st freeJ '+sy mem#ry lists 8( G# fet&h ne t -#'
'EALLOCATION
0
Chapter 2
The pr#&ess #f freeing an all#&ate! res#+r&e$ )hether mem#ry spa&e$ a !e,i&e$ a file #r a C"U(
T,e s+stem -re-are. for t,ree a!ter ative sit/atio s 0Ma. ic1 2 'o ova , 34567
Case /: Khen the 'l#&* t# 'e !eall#&ate! is a!-a&ent t# an#ther free 'l#&*( Case 2: Khen the 'l#&* t# 'e !eall#&ate! is 'et)een t)# free 'l#&*s( Case 0: Khen the 'l#&* t# 'e !eall#&ate! is is#late! fr#m #ther free 'l#&*s(
RELOCATA(LE 'YNAMIC
A Mem#ry all#&ati#n s&heme in )hi&h the system rel#&ates pr#grams in mem#ry t# gather t#gether all #f the empty 'l#&*s an! &#mpa&t them t# ma*e #ne 'l#&* #f mem#ry thatBs large en#+gh t# a&&#mm#!ate s#me #r all #f the -#'s )aiting f#r mem#ry( Hil#'yte ;H< : a +nit #f mem#ry st#rage spa&e e.+al t# /$2A1 'ytes #r 2/A 'ytes( Rel#&ati#n : the pr#&ess #f m#,ing a pr#gram fr#m #ne area #f mem#ry t# an#ther( Rel#&ati#n register :a register &#ntains the ,al+e that m+st 'e a!!e! t# ea&h a!!ress referen&e! in the pr#gram s# that it )ill 'e a'le t# a&&ess the &#rre&t mem#ry a!!resses after rel#&ati#n(
PARTITIONS
SPECIAL-PURPOSE REGISTERS * are +se! t# help )ith the rel#&ati#n( (o+!d R"gi#t"r * a register +se! t# st#re the highest l#&ati#ns in mem#ry legally a&&essi'ly 'y ea&h pr#gram( R"lo,atio! R"gi#t"r * a register that &#ntains the ,al+e that m+st 'e a!!e! t# ea&h a!!ress referen&e! in the pr#gram s# that it )ill 'e a'le t# a&&ess the &#rre&t mem#ry a!!ress after rel#&ati#n(
:the !ata ,al+es :initiali7e register / $SSEM)LY L$NGU$GE :initiali7e register 2 #R%GR$M :a!! ;A G reg /< t# reg 2 :a!! / t# reg 2 :is reg /(1-/5 :if n#t$ g# t# l##p :if s#$ m#,e reg 2 t# reg 0 :!i,i!e reg 0 'y 1 :remain!er t# register 1 :en!
A EL" /02$ /11$ /23$ //A IEG2N: MOME2 /(A MOME2 2(A LOO": A%% 2(A;/< A%%2 /(/ CA2G /(1$@UM" LOO" MOME 0(2 2%2M2 0(1 EL2T EN%
Chapter 2
AAAAAAB AAAAA/B AAAAA2B AAAAA0B AAAAA1B AAAAA3B AAAAA6B AAAAA8B AAAAA9B AAAAA:B AAAA/AB AAAA//B AAAA/2B
AAAAAA AAAAAA AAAAAA AAAAAA 2A/ 2A/ 28A 28/ 0A8 021 2AA 20/ A18 A/ A2 A2 A/ A/ AA A0 A0 A/
AAA/02 AAA/11 AAA/23 AAA//A A A A A A A A A A AA AA AA AA AA AA AA AA AA AAAAAA AAAAAA AAAAAA AAAAA/ AAAAA0 AAAAA6 AAAAA2 AAAAA1 AAAA/2
A:
EL"/02$/11$/23$//A
AAAAAA
EN%