Академический Документы
Профессиональный Документы
Культура Документы
Chapter
Ch t 7
Memory Management
Dave Bremer
Otago Polytechnic, N.Z.
©2009, Prentice Hall
The need for memory
management
• Memory is cheap today
today, and getting
cheaper
– But applications are demanding more and
more memory, there is never enough!
• Memory Management
Management, involves swapping
blocks of data from secondary storage.
• Memory
M I/O is
i slow
l comparedd tto a CPU
– The OS must cleverly time the swapping to
maximise
i i the
th CPU’
CPU’s efficiency
ffi i
Memory Management
Memory needs
M d tto be
b allocated
ll t d to
t ensure a
reasonable supply of ready processes to
consume available
il bl processor time
ti
Memory Management
Requirements
• Relocation
• Protection
• Sh i
Sharing
• Logical organisation
• Physical organisation
Requirements: Relocation
• The programmer does not know where the
program will be placed in memory when it
is executed,
executed
– it may be swapped to disk and return to main
memory at a different location (relocated)
• Memory references must be translated to
the actual physical memory address
Addressing
Requirements: Protection
• Processes should not be able to reference
memory locations in another process
without permission
• Impossible to check absolute addresses at
compile time
• Must be checked at run time
Requirements: Sharing
• Allow several processes to access the
same portion of memory
• Better to allow each process access to the
same copy of the program rather than
have their own separate copy
Requirements: Logical
Organization
• Memory is organized linearly (usually)
• Programs are written in modules
– Modules
M d l can beb written
itt and
d compiled
il d
independently
• Diff
Differentt degrees
d off protection
t ti given
i tto
modules (read-only, execute-only)
• Share modules among processes
g
• Segmentation helps
p here
Requirements: Physical
Organization
• Cannot leave the programmer with the
responsibility to manage memory
• Memory available for a program plus its
data may be insufficient
– Overlaying
O l i allowsll various
i modules
d l tto be
b
assigned the same region of memory but is
time consuming to program
• Programmer does not know how much
space will be available
Partitioning
• An early method of managing memory
– Pre-virtual memory
– Not used much now
• But, it will clarify the later discussion of
virtual
i t l memory if we look l k first
fi t att
partitioning
– Virtual
Vi lM
Memory hhas evolved
l d ffrom the
h
partitioning methods
Types of Partitioning
• Fixed Partitioning
• Dynamic Partitioning
• Si l P
Simple Paging
i
• Simple Segmentation
• Virtual Memory Paging
• Virtual Memory Segmentation
Fixed Partitioning
• Equal
Equal-size
size partitions (see fig 77.3a)
3a)