Transcript
-225: *'1," )&)$,-4' ')$(" 2009
. . )&)$,-4' © ' $,- $) *-"+
16: (Virtual Memory) *)# , 1+ *,% . 15 ). 2009, 4* 23:59 () 13) [printer version - PDF] [Up - Table of Contents] [Prev - 15. Cache Memories] [17. I/O and DMA - Next (Sp'06)] (&&. %),"): $,- -) 3- *) $,. -). % /&). 7 -- 2 § 7.4 %$ *-- , &. 529-583, %$ $$- * -$+ , &. 529-561.
16.1 SRAM, DRAM, (Interleaving):
,
SRAM-DRAM: 1+ ,-) #" , - chips ' "+ '$ )*'1 ' ,1- *$% , % ), blocks 2 ,-)$0 ' "+. -$+ ",--$%+" ' + (SRAM - Static Random Access Memory), - ,-)$0 ' "+ '$ flip-flops ( 6 transistors %#'), %$ " )#"% . '" &"*)/)* $-"* -$ 2,) '$ ' '" " -," -*)/)),+. -$+ ".' $%+" ' + (DRAM - Dynamic Random Access Memory), - ,-)$0 ' "+ '$ .%'1-+ (capacitors --'+
.%'1-+ %$ ' transistor ' bit), 2 ). )#"% 3 -$ .' $% "
&"*)/)*. 21 -). * 3 -)+ $**)+, " &"*)/)* .- (/)*-) ,-)'
.%'1-), 0' -$ , , & 0$&$),- -). .- *)& -). (ms). $ ' $-"*"#)3' - *$ 02 ' -"+ DRAM * $ ' - '!1))')3 (refresh), "& ' - $!). %$ ' - ('*/). , %# * ). 8 16 ms. ( - Mbits): * -) $)'%-" -).+ .-2, %$ * -"' &3- *" %#.,-*"," *), &,"+ ). 0).', )$ DRAM $#-).' ' ," '-$%2 & )'%-" : *),/*).' * ). -(" #).+ &3- *" 01*"-$%2-"- (capacity, Mbits --20$ "capacitance") ' chip , ,0," -$+ SRAM. -,$, )$ DRAM 0*",$ ) )$)3'-$ ,0 2' '- $ -"' %-,% . -"+ %3*$+ ' "+ (main memory) -1' . )&)$,-4', '4 )$ SRAM 0*",$ ) )$)3'-$ ,0 2' '- $ -$+ %*./+ ' + (cache memories), &21 -"+ 0 "&2- *"+ %#.,-*",+ -).+. -"' *2)) -"+ - 0')&)+ %-,% .+ )&)%&"*1 '1' %.%&1 -1' (chips), " 01*"-$%2-"- -1' chips ' "+ ,.' 04+ .(' $. $+ - & .- + % - +, ) *.# 2+ .-+ -"+ 3(","+ -': (x4) 01*"-$%2-"-+ %# (3) . * '$
* ). -2,)+ (,1+ &) 0 "&2- *)+) .-2+ ) *.# 2+ 3(","+, %$ '$
)&3 $#'2 ' ,.' 0, $ -,$, ' %$ % )- &&)' # , $. - , -"+
*4-"+ % -+ -). 21). $4', " - 0')&) -1' DRAM *,% -$ 3*1 ,-)
1 of 10
1 Gbit chip (.(. . www.micron.com). !", % %* &!!$%- % "$ # $ "# %# (modules - DIMM), !& ( * %# $&*# 8 ( 9) 16 ( 18) chips. %$, module 8 chips %* 256 Mbits ( $&! (*"%+%% 4 Gbits = 256 MBytes, - %$%!(! module 16 %%! chips "!$'" 512 MBytes. % % chips 9 % 8, 18 % 16, % ! chips ("$!!!,% !&$ ** (&$# +"*$# $'%* (ECC - error correction codes). : $ $%! chip %# #, %! block # "!& %%"*!# # + $%!( #, ,"* $%# 64 *# 512 "# 64 *# 512 $%#. $!& $%!(! # !& "-% % " $% !! &%+, !%# % ,&$ "# (row address) $%! !*!!% "#, ! !!!# $," (word line) !& %"( "!! % &% ". % ) %! $," &%+, + % $%!( # (bits) * $% " &% !%, %!!%!, %! % % %!& ("(++ %!&) $%! %$%!(! $," $%# (bit line) !& %"( % $% %!&. %$, $%! %* "!# %!& block %# #, $%# ! # %* $&"%* $%#, '% %! "(+! +* %* bits !& !& $% $ ". # !# !&%# %+% %! bit !& # , $ %# ,&$# $%# (column address), %! "!# % *. + &% $, + % $!! %# ,&$# "# (" %! %+ bit $% !!, " "%+ ("+! (,"* $% 60 ns %# $"# DRAM). (sequential Accesses): % % "* $, +*#, !& $!& " + % "" bits &%!, !& +# $, %+% &%+ !" !, "!"+%": % bits &% "%!", $%# ! # %* $&"%* $%#, %! chip %# # !" % !$% $%! %!,% % *$ (.(. %! "$%) !, "!" %! % %! ! ("!& 1 bit 2 5 ns $ + % $,"% !* (data) %# $"# DRAM). %&+! % &%+%% &%, %&(!& "!$,!& # !# %!- * (.(. cache lines (blocks)) !, " ! "&$ $ $($ % "( &$%"$ "!$$# %# "-%# # %# !#. (Interleaving): %( !& ("$!!% % , $ %# "!(# (throughput) # # --&"*# "!$$# $ %&(# &,$# +( %+$! $&(+# &,$#-- (Memory Interleaving). % %( &%, +% ! &,$# !& !$%!% $' $,$% # (.(. chip) '"!% $ '!"% + % blocks (memory banks) !& &%+ "(,
2 of 10
)/) % &*/' %()%"' ))% .# *0#(.# --! % #)()% ,%' &*/' #&$' &%( "(.#-- # %"0 -"/)&%' / )%# &*/ &%( "(.# ( ! # block (bank), %#%* /) ) blocks (banks) %*"0%*# # &"""., ' # )&/ % %* * %%, & (pipelining).
16.2 , , :
!%# ! # ,&( % % ) )&' !*&.' (!% %0': i. &%()( )$0 ).# %"" "1# &( 1# (processes) %* )&,%*#. ii. #$&)( *0#(.# )$0 ).# &( 1# *)1#. iii. 2*#)/)) ! &( # "" " ,1&% #' "0)&% / )% !%) )' +*( !' #' %* /#).' )' )) . ( !/' )&/ %' " )%*&' )' !%# !' #' # % $'. 0*#( #' %* ## % $&()' --" )% &/& %* )&, -- .&) .' " ", ! ( # "", " ", &%)%0 % () # # " "$ )# % % )" ! &%( "( )% &/&. )+&( *) +&%#) : i. ", /) &( %* )&, , !. # !# )# &%( "( %* ) (##.(/&+/!)"() () 0*#( %* ). ii. )+& ) ' !%# !' *0#( ' )' ! &(' ( +%&) !' +*( !' *0#( ' )# ! &(, !)/' ).# & )1(.# %* "%* % &(' # !% #.#%0# )$0 )%*' (. !% #/,&()' #' (shared memory). iii. )+& ) ' / (*,# ( )%* &/#)%') ,&( % % %0#' !%# !' *0#( ' () ' +*( !' *0#( ' / %* *)' ",.&#", #1 /(' # ,.&# ()# * &,%*( +*( ! # &%!"%0# (+" ("' (page fault - § 13.1), 1() # +&%#)( )% " )%*& !/ (0() # ) ' +& ((*#.' / )% (!%).
)+&( *0#(.# #) !%#%#)' %"/!"&' " " (pages) !%# !' #' ( %"/!"&' +*( !' ("'. % %' )' ("' # &!) KBytes (&, ! )( # # "1# ) ,&/# . # #) )+&( &%&, ,&( % % ) (*#.' #' !&/' !)"%%' *1# !%# !'-+*( !' ("' ) ' / (*,# ,&( % % %0#' ("' --% "TLB" (Translation Lookaside Buer)-%&#.#%' (# !& !&*+ #, (*#.' "&.' &%() & () !. )# # !%# ! (" # )# &(!%* ()%# TLB, )/) )# #) ()%*' , %* &(!%#) () #. .&() )% $' !&/ ($. &) !/ (&) (0() !%# !' #', (# "/ & . 3 of 10
!%# !' *0#( ' ,%*# %' 20 bits (". # #)-+ ' ()% !$ !/ (0()), & % ,1&%' !%# !1# *0#(.# # 1 MByte # &(. %' ("' = 4 KBytes, & ) 12 LS bits ! 0*#(' (3 LS !$ ! -+) "%*# 1 byte ( () (", #1 ) * /"% MS bits * %"1#%*# % (" ". )( , ! &( , 256 !%# !' ("' (1 MByte / 4 KBytes = 256).
+*( ! # # 64 KBytes, & % +*( !' *0#( ' %)"%0#) / 16 bits (4 !$ ! -+), %#.' * &,%*# 16 +*( !' ("' (16 KBytes / 4 KBytes = 16). /), )+&( ' !%# !' 0*#(', .,. )' FE210, ()# #)()% , +*( ! #) .' $': .&%* )# !%# ! 0*#( () 12 LS bits, %* * %"1#%*# )% byte ( () (" (1: 210), ! () 8 MS bits, %* %&%*# )# !%# ! (" (1: FE). 12 LS bits (210) # ,& %#) )+&(, +%0 !%#%* %"/!"&' !%# !' ("' ( %"/!"&' +*( !' ("', ! /"' % ("' # **& (#' () +*( ! /& )%*'. 8 MS bits, " % & /' !%# !' ("' (FE), ,&( % % %0#) (# index ()%# #! )+&(' )' &(' (process) %* )&, *) ) () . #!' *)/' , %' 256 ( ' --/(' ! % !%# !' ("' # &(. &, #!' )+&(' , )( 1() ! &( # %& # , ) ' !' )', +%&) !', +*( !' ("', & )% %#/' /) ,&( % % ' !%# !' *0#( ' /"' ) ' ""' &('. ) ( FE )%* #! )+&(', / %* ' %(# ) 8 MS bits )' !%# !' 0*#(', * &,%*# "&%+%&' --/ .' %0 &!).-- # "$%* # !%# ! (" FE %* "%* * &, () +*( ! #, ! # ,%* !. # )# &%( "(%* / .' ) )&,%*( &(. ) ( FE )%* #! )+&(' &(!%* )%# & / )' +*( !' ("' / %* &(!) *) ) () !%# ! (" FE. )% & ', * &,%*# 16 +*( !' ("', & % & /' +*( !' ("' , 4 bits. (). /) &! )%# & / A (# & / +*( !' ("'. *)/# !%" ! ) 12 )+&() LS bits )' !%# !' 0*#(' (210), ! +) ,#%* )( ) 16 bits )' +*( !' 0*#(': A210, ()% & '. : )% hardware )%* $&() &(! )%# #! )+&(' )' )&,%*(' &(' / ) (+*( !) 0*#( (' )%* #! *)%0, %* # &# ( / )% " )%*& !/ (0()) (' ## !/ !),.&) )%* (*())%' ,& (' #' --/,
4 of 10
#$ * register file. $ !#$" $!' # "user mode", $!$ !( %$* $ $')!$, +$)" ,#$ ! % ! *$ !#, ! $# !*## #$ ) !#,. : !) *" $')!$" % ! $ $!' $ $&!#" -- $ $!' %# !#-- ! ## " * $ !#$ * *$ !#$" !#$ # "kernel mode", $!' $ $ %!* #+#$. !# (exception) --!* % $ % #$ " #%#$$ " (system call)-- + $ $#$# (user/kernel) #$ $!' !#$", &! $ !#$ # kernel mode. $#, trap (exception) handler $$ $ # kernel mode, , * " $!* " '!#$ &! $ !#$ # kernel mode ! # !#, $*$" $ system call --$ # ! $ % ! !#, % $ $ %!* #+#$ ! *$ ! !$ # system call *' # ! $ *) ! !$#$ + #&$ ". # #%#$$ " $" &$ #%!&!$ # !# (exception), *' # * # #" ($ jal), +$)" ,#$ # " #$ $ %!* #+#$ -- % ! # kernel mode-- $ * #$ ! !# +%# $ % trap handler, *' # $ %!$ +%# ! +# $# " * % " '!#$" ! % !( $ ! " $ % $ %! + #%#$$ " % $ %" ' %" $ % '!#$" ' ) $# %$* % $. / : # $ % $&!#" !': "valid bit", % % + # #$ &!*#$ ! +# +# * $ &%# . '* %# $" " #" * $ &%# ! &$ $ #$ *$ %$ # ( '!# $, $ !*! ' $ " , +$ $# $ #) malloc/sbreak), $ #$ *$ * %$ $ #$ !#$ *' #$ . (4 bits #$ , ! ") * % !#$ %$ $ #$ #, *$ %$ ! +# #$ &%# . "bits " (.'. 3 bits: "rwx"), % , % $ %" ! ##" $!$ ! +# !# #$" " %$" $" #". "dirty bit", % ' !#$" *' $ !'*
5 of 10
! % % ! % .
"reference bit", ! # !% & % "LRU": , ! % bit, ' !% & ! bits # %" , ! # .
16.3: () $ % ($ % ) , # % ! # #$ ! # pointer " & , ", &! (20 bits) ! , % ! , % ! # index ", ! % ! , ' ! ! "! &! (16 bits). () $ % , $ % , # : 00: ( # NULL pointer). 01: # ' (r-x), "! 7. 02: # ' (r-x), "! C. 03: # (rw-), "! 0, dirty. 04 $ 09: & % "! . 0A $ 9F: (unallocated). A0: # ! (r--), "! D. A1: # ! (rw-), "! E, dirty. A2 $ A5: & % "! . A6 $ FD: (unallocated). FE: # (rw-), "! A, dirty. FF: # (rw-), "! 1, clean. ( #% ! " , #$ reference bits % ! (256 4 -- # $ '...).
6 of 10
() '") 0 +") (#+/ ('* $*") *+") "#'%"#) ",!1%*") ', '%+" ('#$'1% *-$ *$); " , 0$'" ), * '" -,*"# "1!,%* +-('%+"; 02038 (fetch), 03FF4 (read), A001C (write), 0192C (fetch), 00000 (read), 92FC0 (read), FE5D8 (write), 03FF4 (fetch), A1FFC (read), 008F4 (write), A2000 (read), 01E40 (write).
16.4:
-
" ("**0+() "(*) .( *" ' '"'1% *.+"# $) 0 +") "#'%"#) +',) *$), #" ,+) *,%'! $, %) (clustered) * ("#) ""+'%")", 0 /) *+ % ( %/ *# * 16.3. # +$$,0 %'" ,+ + % ""0+ +, '('1 % "2*', +' .2(' % ) ', #+$ %" ' %#) +-(* ) + ) #! "(*), * '%+) +'% * ("#'1) "#(0+(',) %#), '(%/ %',) *% " '$,- "((.. /(*+ 0+" *+' *1*+ % ) + ) *# * ) 16.3 $$', +'% '%"#0 ( '%' ') %# +-(* ) % "(* * " ',) %#), 2) &). ! "(* ." %% %# (2+', " ',, !',) 16 !*/%. '% %# ,+0% +'% (*#', */ +', %/*+'1 pointer ', (".+" *+'% ""#0 #+./( + ', %-( ( %/. ( *" ' '"'1 + 4 MS bits + ) "#'%"#) "1!,%* ) " % "$&', 0 +") 16 !*") ,+'1 +', %#. ! *,%,* 0) +/% 4 ,+2% bits, ' %/) #" #! !* ,+'1 +', %#, %+"*+'". * 16 "#'%"#) *$). % # 0 ,+) +") 16 *$) % , (." *+ -,*"# % , +0+ * "2%', + !* ,+ +',
%# (2+', " ', *% #,( (valid bit = 0). $$'"2), !* ,+ +',
%# (2+', " ', ("." %% pointer * % %# +-(* ) ,+(', " ',. % "#'%"# ) "1!,%* ) ' * * ++'" !* *+'% %# (2+', " ',, +0+ .( *" ' '"'1 + 0 % 4 bits + ) "#'%"#) "1!,%* ) *% index *+'% %# ,+(', " ', 0 ', ) ' * ' %#) (2+', " ',. #, *+'% %# ,+(', " ',, (*#', + +$"# *+'". " + *$ ', + . () %+ % "( %$'' (') ,+0 + ) *# * ) 16.3() " +' " ' *1*+ +-(* ) ,+) + ) *# * ). +' "' "( , &+ 0$',) +',) %#) ,+(', " ', ', ! , (.',% " +") *$) + ) *# * ) 16.3(). * ) &+, 0$ + (".0 % 0$/% +/% "%#/% +-(* ), (2+', #" ,+(', " ',. "/!+ (./() % 2*+ ( + + % %+ * *)) 0+" +' *1*+ ,+0 +-(" +") ",!1%*") + ) *# * ) 16.3() +' "' 0 /) #" +' '%' ' *1*+ + ) *# * ) #% ).
7 of 10
() /)( )!( $( "*#$&+$ /#&! &! $"( *,')( *&+ '/$*&( ! &+ )+)**&( ! * !') ( "! ! *!( )#( (); )-) *& &$& & )0)* *( )")( 16.3() + '-! &!"&$& )*& -1'& $( &+ "*#$*!;
16.5:
" # $#* *$ )") 16.4() -- &+ *$ )$ *$ 16.3() ()-*!"/ !' !$".$ *,')()-- +* * ,&' ! $ '#!)*!"/, )'!$/, )0)* !"&$!"( $(: ! !"&$!"( !+ 0$)!( -&+$ &( 64 bits. .(, ! '"*!"&0( #/&+(, &$& * 46 LS / +* -')!& &!&0$*! (-1'&( !"&$!"1$ !+ 0$).$ 16 TeraBytes $ !')...). ! $ $ &+$ &! -')*( )*& !')/ $ ""*##+*&0$" ! ##& )"& / * 18 MS bits *&+ " pointer &+ '!))0&+$ ---$&$*( *)! *& portability *.$ '&'*.$ *&+( ) ##&$*!"( $!( )+)**.$ '!))/*' +#& &!$ bits !"&$!"( !0 +$)(-- *& )0)* ( #-! " '&) #) $( ! $ )!&+'+* /*! +* * 18 MS bits *( !0 +$)( !)&0$*! /# *& MS bit *.$ 46 LS bits, # &*#&0$ "*) '&)&+ (sign extension) *&+ +#& &!$&+ '&+( *( !"&$!"( !0 +$)( (*)!, &' )*& $ )+$-)! $ *& & **! )*& $. "'& *&+ !"&$!"&0 -1'&+ $( (!+ 0$)!( FFFFFF...). &( )#( 64 KBytes. &$.( * 16 LS bits *( !"&$!"( !0 +$)( $ -'!&$*! *,'). ' !$".$ *,')( $ !'). $"( *,')( -! &( 1024 )!(, ' ""&!*!" 10 / * bits *&+ '! &0 !"&$!"( )#(.
16.6: TLB, Process ID, "! .( "! ' $., ! $ $*! *,') '&', -')!& &!*! )+$ .( $( !"'/( "*#&&( +1$ !"&$!"(-,+)!"( )#( ! *!( !/ )+-$ -')!& &!&0$( )#(, & "TLB" (Translation Lookaside Bu2er), &'$.$&( )$ ! !"' "'+, $, )+$ .( #'.( '&)*!'!)*!". '&"!$&+ $ $ $"/)* $ "+'1$&+ * '!-/$ *&+ TLB ) " ## *( !')( &+ *'-! (context swap), #&+ $ &'&0 $ -&+ ) )*& TLB, *+*/-'&$, +'! !"&$!"(-,+)!"( )#( #1$ !,&'*!"1$ !')!1$. +*/ /.( !* $ &'&0 $ * %-.'&+ *%0 *&+(, ,&0 *$ " &'!)$ !"&$!" !0 +$) $-*! $ *$ -')!& &!&0$ #( !')( ## ! !,&'*!" #'&,&' "! "*
8 of 10
)#$', '$,# . ! !' # *+$&,% (',%, '$)#( '#! $, $&% ("PID", Process Identifier) '#! $, #!% & % ('% '% $&% & & (($ #!%-)(&% & %) '#( TLB. () +$&' '! #! ! '% &&% 16.3, +$&' ,' '# PID * #% 8 bits (*$ 256 '(',*$#!% $&%). +$&' ! TLB #(% 16 &+!, $+% $#&'$&' '##'& (.! (###' -#% ')$&% #$ ! ##(#' &'# TLB). # $ ! * & ('#- '#( TLB, ' #(% '# !; () /.&' ! $', $ '#( $#(% $*#!#( '#( TLB ,'! (', $* ($ ')$&% '% "% & %: ! #! & 01 '% $&% 3B ($* .), '! #! & 01 '% $&% B4 ($* data r/w), # ##% !)$#!' & !' .% )#$'%, !"$''% )(&% & %. $& 3B $& 3C #' #-! )#$'% !$##&% '#( #( $#$'#%, .*. # #% web browser '$!#% , -# )#$'#-% *$&'%. ##!# ()(&%) !%, '# '#($, &-&' $' ,!# ! !''(# '#( . ('% '% )$#% &' !, ! , % '% $&% #( '# '$*#(! ! " #(!" (', '# #!, #!,*$&'# !''(# &' '% #! ! . ' #,! &'# TLB '! #! & 01 '% $&% 3C, #( $* '#! # . ' & 01 '% 3B.
' '! #! & FF '% $&% 3B, '! #! & FF '% $&% 3C, #( $*#(! #! &'#%. +% , ('% # -# $&% #' #-! )#$'% !$##&% '#( #( $#$'#%. $ '# #!,% ,' # .% '+! -# ('.! $&.! ! #!,%, ' #! '#(% ,+% ! )#$', )#- .*. ! # !% *$&'% '#! web browser '#(, # #%. $&% D2 D3 &(!$#!' '"- '#(%, #!+!#-! &+ #!,*$&'% !%: $& D2 $ #! $#% "$&, ' $) &'! #! & '% A0 ($#&'& -w-). $& D3 '! .! ' #! #( $ D2, ' "$'. D3 ' #! (' , '! #! & '% C0 ($#&'& r--), ## ,+%, &+ '#( &(&''#% #!% !%, !'&'#* &'! )(& & &'! ## !'&'#* A0 '% D2, .&' ! '(*!' &(!$& $+#--'! +' '+! -# $&.!. ' &'# TLB &% ('% '% -# #!% & %. () $&% 3B 3C, $!+, ! $#&''(!% , '! ; #$ ! & ' #! '% % ( #!'% '&, .*., #
9 of 10
" ! $ & ); ' ( #) (% , ."., " ); # ( #) ' ("'" , ."., " ); ' ! & ' $ & ', ' %" ' % ! % ' " ; : ' % , . ( # , ' ' % " , % ! % %$). [Up - Table of Contents] [Prev - 15. Cache Memories] Up to the Home Page of CS-225
[printer version - PDF] [17. I/O and DMA - Next (Sp'06)]
© copyright University of Crete, Greece. Last updated: 11.05.09, 12:57, by D. Nikolopoulos.
10 of 10