Ch8 Main Memory
Ch8 Main Memory
Operating System Concepts – 8th Edition, Silberschatz, Galvin and Gagne ©2009
Chapter 8: Memory Management
Background
Swapping
Contiguous Memory Allocation
Paging
Structure of the Page Table
Segmentation
Example: The Intel Pentium
Operating System Concepts – 8th Edition 8.2 Silberschatz, Galvin and Gagne ©2009
Objectives
Operating System Concepts – 8th Edition 8.3 Silberschatz, Galvin and Gagne ©2009
Background
Operating System Concepts – 8th Edition 8.4 Silberschatz, Galvin and Gagne ©2009
Base and Limit Registers
A pair of base and limit registers define the logical address space
Operating System Concepts – 8th Edition 8.5 Silberschatz, Galvin and Gagne ©2009
Logical vs. Physical Address Space
Operating System Concepts – 8th Edition 8.6 Silberschatz, Galvin and Gagne ©2009
Memory-Management Unit (MMU)
The user program deals with logical addresses; it never sees the
real physical addresses
Operating System Concepts – 8th Edition 8.7 Silberschatz, Galvin and Gagne ©2009
Dynamic relocation using a relocation register
Operating System Concepts – 8th Edition 8.8 Silberschatz, Galvin and Gagne ©2009
Swapping
A process can be swapped temporarily out of memory to a backing store,
and then brought back into memory for continued execution
Major part of swap time is transfer time; total transfer time is directly
proportional to the amount of memory swapped
Operating System Concepts – 8th Edition 8.9 Silberschatz, Galvin and Gagne ©2009
Schematic View of Swapping
Operating System Concepts – 8th Edition 8.10 Silberschatz, Galvin and Gagne ©2009
Contiguous Allocation
Operating System Concepts – 8th Edition 8.11 Silberschatz, Galvin and Gagne ©2009
Hardware Support for Relocation and Limit Registers
Operating System Concepts – 8th Edition 8.12 Silberschatz, Galvin and Gagne ©2009
Contiguous Allocation (Cont)
Multiple-partition allocation
Hole – block of available memory; holes of various size are
scattered throughout memory
When a process arrives, it is allocated memory from a hole
large enough to accommodate it
Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
OS OS OS OS
process 8 process 10
Operating System Concepts – 8th Edition 8.13 Silberschatz, Galvin and Gagne ©2009
Dynamic Storage-Allocation Problem
Operating System Concepts – 8th Edition 8.14 Silberschatz, Galvin and Gagne ©2009
Fragmentation
Operating System Concepts – 8th Edition 8.15 Silberschatz, Galvin and Gagne ©2009
Paging
Operating System Concepts – 8th Edition 8.16 Silberschatz, Galvin and Gagne ©2009
Address Translation Scheme
Operating System Concepts – 8th Edition 8.17 Silberschatz, Galvin and Gagne ©2009
Paging Hardware
Operating System Concepts – 8th Edition 8.18 Silberschatz, Galvin and Gagne ©2009
Paging Model of Logical and Physical Memory
Operating System Concepts – 8th Edition 8.19 Silberschatz, Galvin and Gagne ©2009
Paging Example
Operating System Concepts – 8th Edition 8.21 Silberschatz, Galvin and Gagne ©2009
Valid (v) or Invalid (i) Bit In A Page Table
Operating System Concepts – 8th Edition 8.22 Silberschatz, Galvin and Gagne ©2009
Shared Pages
Shared code
One copy of read-only (reentrant) code shared among
processes (i.e., text editors, compilers, window systems).
Shared code must appear in same location in the logical
address space of all processes
Operating System Concepts – 8th Edition 8.23 Silberschatz, Galvin and Gagne ©2009
Shared Pages Example
Operating System Concepts – 8th Edition 8.24 Silberschatz, Galvin and Gagne ©2009
Segmentation
Operating System Concepts – 8th Edition 8.25 Silberschatz, Galvin and Gagne ©2009
User’s View of a Program
Operating System Concepts – 8th Edition 8.26 Silberschatz, Galvin and Gagne ©2009
Logical View of Segmentation
4
1
3 2
4
Operating System Concepts – 8th Edition 8.27 Silberschatz, Galvin and Gagne ©2009
Segmentation Architecture
Operating System Concepts – 8th Edition 8.28 Silberschatz, Galvin and Gagne ©2009
Segmentation Hardware
Operating System Concepts – 8th Edition 8.29 Silberschatz, Galvin and Gagne ©2009
Example of Segmentation
Operating System Concepts – 8th Edition 8.30 Silberschatz, Galvin and Gagne ©2009