8.1 Operating System Overview
8.1 Operating System Overview
8
Operating System Support
8.2 Scheduling
Long-term Short-term
Queue Queue
Admit Processor End
I/O 1 Occurs
I/O 1 Queue
I/O 2 Occurs
I/O 2 Queue
I/O n Occurs
I/O n Queue
8.11 Queuing Diagram Representation of Processor Scheduling
8M 16M
8M
(a) Equal-Size Partitions (b) Unequal-Size Partitions
8.13 Example of Fixed Partitioning of 64-Mbyte Memory
4M
(a) (b) (c) (d)
Operating System 8M Operating System 8M Operating System 8M Operating System 8M
Process 1 Process 1 Process 2 14M
20M 20M 20M
6M
Process 4 8M Process 4 8M Process 4 8M
14M
6M 6M 6M
Process 3 Process 3 Process 3 Process 3
18M 18M 18M 18M
4M 4M 4M 4M
(e) (f) (g) (h)
8.14 The Effect of Dynamic Partitioning
a) Before b) After
8.15 Allocation of Free Frames
8.15 5$<6?(.7/-6ก'EJ@6+ Pages 53) Frames A</E+8.3E< L 2)16 Frame E+&+-./0.12%
ก%3(6BCกEJ@6+ 53)16 Frame .-6 <(6+(,+'/ก'F76 Frame .-6 กT2)BCก2(<ก'A</ OS B@ก%&+<E&@ Process A
2(<8กTE+<M$กU9')ก7<@./ 4 Pages <(6+(,+81K7B=68.3A&3< Process A 53@.+(,+ OS กT2)& Frame .-6 L 2%+.+ 4 Frame
53)A&3< 4 Pages F76 Process A 36E+ 4 Frame +,
E+?(.7/-6+, $11?ME&@ Frame ?-78+K76ก(+53)I1-BCกEJ@6+12%+.+I1-8/67$%&'( Process A 5?-9^Q&+ก, IT 1-
%E&@ OS &/V<ก'A&3< Process A I<@ 8+K762ก1ก'EJ@6+ Logical Address 8/65?-I1-I<@EJ@6+ Base Address 8-+(+,
A</ OS 2)<C532(<ก' Page Table $%&'(5?-3) Process A</ Page Table 2)5$<6?%5&+-6F76 Frame $%&'(5?-3)
Page F76 Process +(,+ <(6+(,+E+A9'5ก'1 5?-3) Logical Address 2)9')ก7<@./ Page Number 53) Relative Address
$(1(+PUก( Page 5?-E+ก'GF76ก'% Partition +(,+ Logical Address 2)89:+?%5&+-6F76 Word $(1(+PUก(2V<8'M1?@+
F76A9'5ก'1 2ก+(,+A9'8>$8>7'UกT2)5936 Logical Address E&@89:+ Physical Address 5?-$%&'( Paging +(,+ ก'5936
Logical Address 89:+ Physical Address +(,+2)ก')%A</o'U<5.'UF76A9'8>$8>7'U A</A9'8>$8>7'U?@76'[email protected]8F@B=6 Page
Table F76 Process +(,+ L <(6+(,+81K7EJ@6+ Logical Address >=69')ก7<@./ Page Number 53) Relative Address
A9'8>$8>7'UกT?@76EJ@6+ Page Table $%&'($'@6 Physical Address (Frame Number 53) Relative Address) ?(.7/-6+,
5$<6E+ 8.16
.MP+,5ก@9^Q&8กM<F=,+E+ก-7+&+@+,I<@ &+-./0.12%&3(กBCก5-677ก89:+ Frame 1F+<83Tก8- L ก(+ 5?-3)
Process BCก5-677ก89:+ Page 1F+<8-ก(F+<F76 Frame <(6+(,+ Process F+<83TกกT2)1 Page 2%+.++@7/ 5?-
Process F+<E&Q-กT2)1 Page 2%+.+1ก <(6+(,+81K7+% Process 8F@1 Page ?-6 L F76 Process +(,+กT2)BCกA&3<36E+
Frame $1'BEJ@6+I<@ 2ก+(,+2=6$'@6 Page Table F=,+1
• Virtual Memory
o Demand Paging
81K71ก'EJ@6+ Paging กT2)%E&@') Multiprogramming 19')$MPMก3/89:+2'M6I<@ 53).MP5-6
Process 77ก89:+ Page ?-6 L กT+%I9$C-ก'(w+5+.0M<$%0(Q +(+กT0K7 Virtual Memory
8K7E&@8F@E28ก/.ก( Virtual Memory 2=6?@767PM/8M18?M18ก/.ก(&3(กก'F76 Paging >=6$M68M1F=,+1กT0K7
Demand Paging >=6&1/0.1.- 5?-3) Page F76 Process 2)BCก+%8F@1กT?-781K789:+ Page ?@76ก'8-+(,+
M2'G Process F+<E&Q- >=69')ก7<@./A9'5ก'10-7+F@6/.53)7'U8'/U2%+.+1กF76F@71C3 E+J-.6
8.3$(,+ L ก'9')1.3D3722)2%ก(<7/C-E+$-.+83Tก L F76A9'5ก'18-+(,+ 8J-+ Subroutine 53)60'(,6722)17'U8'/U
F76F@71C38/61 x2 7'U8'/U8-+(,+BCกEJ@6+ >=689:+I9?1&3(กก'F76 Locality <(6+(,+2=689:+ก'$CQ8$/$%&'(ก'A&3<
Page F76 Process +(,+89:+2%+.+1ก 5?-18/6I1-ก Page 8-+(,+BCกEJ@6+ ก-7+A9'5ก'12)&/V<%6+J(. 0'. <(6+(+,
ก'EJ@6+&+-./0.12%2)<F=,+B@A&3<8/6I1-ก Page 8-+(,+ 5?-B@A9'5ก'1 Branch I9/(60%$(67/C-E+ Page I1-7/C-E+
&+-./0.12%&3(ก &'K7B@A9'5ก'17@6B=6F@71C3E+ Page I1-7/C-E+&+-./0.12%&3(ก กT2)%E&@8กM< Page Fault I<@ >=6
89:+ก'7กE&@ OS +% Page ?@76ก'8F@1
<(6+(,+ G 8.3E< L กT2)18/6I1-ก Page F76 Process E< L 8-+(,+7/C-E+&+-./0.12% <(6+(,+2=6%E&@1
Process 2%+.+1กF=,+$1'B7/C-E+&+-./0.12%I<@ +7ก2ก+(,+ /(689:+ก'9')&/(<8.3 8+K762ก Page I1-BCกEJ@
6+2)I1-BCก Swap 8F@53)77ก2ก&+-./0.12% 5?-7/-6I'กT?1 OS กT?@76y3<8/672)'[email protected]2(<ก'&3(กก'+, 81K7
OS +% Page &+=6 L 8F@1 OS กT?@76M,6 Page 7K+ L 77กI9 <(6+(,+B@ OS M,6 Page ?@76EJ@6+E+8.3?-71 OS กT?@76
+% Page +(,+ก3(8F@17กA</(+(+E< >=6B@8กM<8&?Vก'GU5+,-7/0'(,6 กT2)%E&@8กM<$.)8'/ก.- Thrashing
8+K762กA9'8>$8>7'[email protected]A</$-.+E&Q-E+ก' Swap Page 5+2)9')1.3D30%$(6?-6 L 53)ก'&3ก83/6
Thrashing 89:+&(.F@7ก'.M2(/E+J-.6z.''n 1970 53)+%I9$C-7(3ก7'M=1?-6 L 10.1>(>@7+5?-19')$MPM <(6+(,+$M6
$%0(QกT0K7 OS ?@76//18<A</1K,+{+12ก$M68กM<F=,+.- Page E<0.'2)BCกEJ@E+8.3?-71+@7/$V<
81K7EJ@6+ Demand Paging กTI1-2%89:+?@76A&3< Process (,6&1<36E+&+-./0.12%&3(ก >=6F@78T22'M6+, % E&@1
$M68กM<F=,+?11กT0K7 10.189:+I9I<@ Process 2)1F+<A?ก.-8+K,7E+&+-./0.12%&3(ก <(6+(,+F@72%ก(<E+ก'8F/+
(Hash)
Frame #
Frame # Offset
Hash Table Inverted Page Table
Real Address
8.17 Inverted Page Table Structure
.MP7K+ L E+ก'EJ@6+ Page Table 5 1 ')<(&'K7 2 ')<(0K7 ก'EJ@6+A0'6$'@65 Inverted Page Table
<(65$<6E+ 8.17 .MP+,EJ@6++80'K76 IBM AS/400 53)071M.8?7'U RISC F76 IBM (,6&1<>=6'.1(,6 PowerPC
E+.MP+, $-.+F76 Page Number F76 Virtual Address 2)BCกก%&+<36E+ Hash Table A</EJ@6+ Hashing
Function 53) Hash Table 2)17/+U8?7'UJ,I9/(6 Inverted Page Table >=61'/ก'?-6 L F76 Page Table 81K7EJ@6+
A0'6$'@6+, กT2)18/6&+=6'/ก'E+ Hash Table 53) Inverted Page Table $%&'(5?-3) Real Memory Page 5+2)
89:+ 1 '/ก'?-7 Virtual Page <(6+(,+$(<$-.+5+-+7+F76 Real Memory 2)?@76BCกEJ@6+E+?'6?-6 L A</I1-F=,+7/C-ก(
2%+.+F76 Process &'K7 Virtual Page 8+K762ก1 Virtual Address 1กก.- 1 Address $1'Bก%&+<I9/(6'/ก'
8</.ก(+E+ Hash Table <(6+(,+2=6EJ@6+80+M0ก' Chaining E+ก'2(<ก' Overflow +, 80+M0ก' Hashing 2)%E&@
Chain 1F+<$(,+ A</(.I92)1 1 x 2 '/ก'
• Translation Lookaside Buffer
Start
Return to faulted instruction
CPU Checks for the TLB
Cache $%&'(8กT'/ก' Page Table A</(.I92)8'/ก.- Translation Lookaside Buffer (TLB) A</ Cache 2)%
&+@8&1K7+ก( Memory Cache 53)1'/ก' Page Table EJ@6+81K7I1-++1+, 8.18 89:+ Flowchart >=65$<6
ก'EJ@6+ TLB 2ก&3(กก'F76 Locality ก'7@6B=6 Virtual Memory A</$-.+E&Q-2)89:+?%5&+-6?-6 L 7/C-E+ Page
8M6EJ@6+81K7I1-++1+, <(6+(,+ ก'7@6B=6$-.+E&Q-2)8ก/.F@76ก('/ก' Page Table ?-6 L E+ Cache 2กก'z=กnE+
80'K76 VAX >=6EJ@6+ TLB .- &3(กก'+,$1'B9'(9'V6$1''BI<@7/-68&T+I<@J(<
$(68ก?I<@.- ก3Iกก'% Virtual Memory 2)?@76%6+ก(') Cache (I1-EJ- TLB Cache 5?-89:+ Main
Memory Cache) >=65$<6E+ 8.19 A</(.I9 Virtual Address 2)7/C-E+'C9F76 Page Number 53) Offset E+F(,+5'ก
')&+-./0.12%2)0@+&F@71C3E+ TLB 8K7?'.2$7.-'/ก' Page Table ?'6ก(?@76ก'17/C-&'K7I1- B@1 กT2)
$'@6 Real &'K7 Physical Address A</ก''.1 Frame Number 8F@ก( Offset 5?-B@I1-1 กT2)8F@B=6 Page Number +(,+
A</ก'EJ@6+ Page Table 81K71ก'$'@6 Real Address >=67/C-E+'C9F76 Tag 53) Remainder <(65$<6E+ 4.17 +(,+
กT2)?@760@+&E+ Cache 8K7?'.2$7.-13T7ก1 Word +(,+7/C-&'K7I1- B@1 กT2)$-6I9E&@A9'8>$8>7'U 5?-B@I1-1 กT2)<=6
Word 12ก&+-./0.12%&3(ก
TLB Operation
Virtual Address
Page # Offset
TLB
TLB Miss
TLB Hit
Cache Operation
Real Address
+ Tag Remainder Hit
Cache
Miss Value
Page Table
Value
Main Memory
8.19 Translation Lookaside Buffer and Cache Operation
ก'5936 Virtual Address E&@89:+ Real Address 2)8ก/.F@76ก(ก'7@6B=6 Page Table >=6722)7/C-E+ TLB, E+
&+-./0.12%&3(ก &'K7E+<M$กU 53) Word 7@6B=6722)7/C-E+ Cache, E+&+-./0.12%&3(ก &'K7E+<M$กU E+ก'GF76
Word +(,+ Page 1 Word +(,+2)?@76BCกA&3<36E+&+-./0.12%&3(ก53)3T7กF76 Word 2)BCกA&3<36E+ Cache 53)
'/ก' Page Table $%&'( Page +(,+กT2)?@76BCก9'(9'V65ก@IF<@./
• Segmentation
.MP7K+ L E+ก'5-6&+-./0.12%$1'B7@6B=6I<@0K7 Segmentation 8+K762ก Paging 2)I1-$1'BEJ@6+A</
A9'5ก'1817'UI<@ 53) Paging BCก77ก5$%&'(2V<9')$60UF76ก'8?'/18+K,757<8<'$F+<E&Q-E&@ก(A9'5ก'1817'U
5?-ก'% Segmentation +(,+2)$1'BEJ@6+I<@A</A9'5ก'1817'U 53)2(<8?'/10.1$)<.ก$/E+ก'2(<ก'A9'5ก'1
53)F@71C3 53)89:+.MPก%&+<$MPMM8zn53)976ก(+0%$(653)F@71C3