Академический Документы
Профессиональный Документы
Культура Документы
Third Edition
ANDREW S. TANENBAUM
Chapter 3
Memory Management
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
No Memory Abstraction
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Multiple Programs Without Memory
Abstraction
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Base and Limit Registers
Figure 3-3. Base and limit registers can be used to give each
process a separate address space.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Swapping (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Swapping (2)
Figure 3-5. (a) Allocating space for growing data segment. (b)
Allocating space for growing stack, growing data segment.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Memory Management with Bitmaps
Figure 3-6. (a) A part of memory with five processes and three
holes. The tick marks show the memory allocation units. The
shaded regions (0 in the bitmap) are free. (b) The
corresponding bitmap. (c) The same information as a list.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Memory Management with Linked Lists
1024k Free
Buddy System
A • A needs 100k
128k
• Divide memory into two 512K blocks
128k • Divide first into two 256k blocks
• Divide first into two 128k blocks
• Assign A first of these
256k
Part
Part Free
512k
Part Free
Full Free
Buddy System
A • B needs 300k
128k
• Search left
128k • Stop at second branch because it is not free
• Search right
• Assign B 512K block
256k
Part
B
Part Full
512k
Part Free
Full Free
Buddy System
A
128k • C needs 200k
• Find leftmost block that fits
128k • Assign C 256K block
C
256k
Part
B
Part Full
512k
Part Full
Full Free
Buddy System
A
128k • D needs 50k
D 64k • Split 128K block
64K • Assign C first 64K block
C
256k Part
Part Full
B
Part Full
512k
Full Part
Full Free
Buddy System
128k • Deallocate A
D 64k • Buddy is part full; just free A
64K
C
256k Part
Part Full
B
Part Full
512k
Free Part
Full Free
Buddy System
• Deallocate D
256k • Immediate buddy is free; merge
• One level up, buddy is free; merge
C • Mark 256K free
256k Part
Part Full
B
Free Full
512k
Buddy System
• Deallocate B
256k • Immediate buddy is not free
• Just free 512K
C
256k Part
Part Free
Free Full
512k
Buddy System
• Deallocate C
• Immediate buddy is free; merge
• Next buddy is free; merge
• Mark all 1024k free
1024k Free
Virtual Memory – Paging (1)
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Speeding Up Paging
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Translation Lookaside Buffers
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Multilevel Page Tables
Figure 3-13. (a) A 32-bit address with two page table fields.
(b) Two-level page tables.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Inverted Page Tables
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Second Chance Algorithm
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
LRU Page Replacement Algorithm
Figure 3-17. LRU using a matrix when pages are referenced in the
order 0, 1, 2, 3, 2, 1, 0, 3, 2, 3.
Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Simulating LRU in Software