8/6/2019 Chapter 4 Memory Management-part1
1/28
Operating Systems:
,William Stallings
ap er
M m r M n m n
Dave Bremer
Otago Polytechnic, N.Z.2009, Prentice Hall
8/6/2019 Chapter 4 Memory Management-part1
2/28
The need for memorymanagement
,
cheaper
more memory, there is never enough!
,blocks of data from secondary storage.
emory s s ow compare o a The OS must cleverly time the swapping to
max m se e s e c ency
8/6/2019 Chapter 4 Memory Management-part1
3/28
emory nee s to e a ocate to ensure a
reasonable supply of ready processes toconsume ava a e processor me
8/6/2019 Chapter 4 Memory Management-part1
4/28
Memory ManagementRequirements
Protection
ar ng
Logical organisation Physical organisation
8/6/2019 Chapter 4 Memory Management-part1
5/28
program will be placed in memory when it,
it may be swapped to disk and return to main
Memory references must be translated to
8/6/2019 Chapter 4 Memory Management-part1
6/28
8/6/2019 Chapter 4 Memory Management-part1
7/28
memory locations in another process
Impossible to check absolute addresses at
Must be checked at run time
8/6/2019 Chapter 4 Memory Management-part1
8/28
8/6/2019 Chapter 4 Memory Management-part1
9/28
Requirements: LogicalOrganization
Programs are written in modules
o u es can e wr en an comp eindependently
eren egrees o pro ec on g ven omodules (read-only, execute-only)
Share modules among processes Se mentation hel s here
8/6/2019 Chapter 4 Memory Management-part1
10/28
Requirements: PhysicalOrganization
responsibility to manage memory
data may be insufficient ver ay ng a ows var ous mo u es o eassigned the same region of memory but is
Programmer does not know how much
8/6/2019 Chapter 4 Memory Management-part1
11/28
8/6/2019 Chapter 4 Memory Management-part1
12/28
Dynamic Partitioning
mp e ag ng
Simple Segmentation Virtual Memory Paging
8/6/2019 Chapter 4 Memory Management-part1
13/28
8/6/2019 Chapter 4 Memory Management-part1
14/28
.
The programmer must design the program
Main memory use is inefficient.
, ,an entire partition.
.
8/6/2019 Chapter 4 Memory Management-part1
15/28
Solution Unequal SizePartitions
but doesnt solve completely
. ,
Programs up to 16M can be
Smaller programs can be placed in
,fragmentation
8/6/2019 Chapter 4 Memory Management-part1
16/28
-
Placement is trivial (no options)
-
Can assign each process to the smallest
Queue for each partition
rocesses are ass gne n suc a way as ominimize wasted memory within a partition
8/6/2019 Chapter 4 Memory Management-part1
17/28
8/6/2019 Chapter 4 Memory Management-part1
18/28
Remaining Problems withFixed Partitions
by the system . -
partitions
not use the space efficiently
methods
8/6/2019 Chapter 4 Memory Management-part1
19/28
number
memory as required
8/6/2019 Chapter 4 Memory Management-part1
20/28
Dynamic PartitioningExample
Ex rn l Fr m n i n
Memory external to allP2
Can resolve using
(20M)
Empty (6M)
OS moves processes so(14M)
(56M)Empty (6M)
Time consuming and
P3(18M)
Empty (4M)
Refer to Figure 7.4
8/6/2019 Chapter 4 Memory Management-part1
21/28
block to allocate to a process-
Chooses the block that is closest in size to the
Worst performer overall
nce sma es oc s oun or process, esmallest amount of fragmentation is left
8/6/2019 Chapter 4 Memory Management-part1
22/28
-
Scans memory form the beginning and
enough
May have many process loaded in the frontend of memor that must be searched over
when trying to find a free block
8/6/2019 Chapter 4 Memory Management-part1
23/28
8/6/2019 Chapter 4 Memory Management-part1
24/28
actual (absolute) memory locations are
A process may occupy different partitions
locations during execution
wapp ng Compaction
8/6/2019 Chapter 4 Memory Management-part1
25/28
Reference to a memory location independent.
Relative
some known point.
The absolute address or actual location in
.
8/6/2019 Chapter 4 Memory Management-part1
26/28
8/6/2019 Chapter 4 Memory Management-part1
27/28
Registers Used during
Execution
Starting address for the process
Ending location of the process These values are set when the process is
loaded or when the process is swapped in
8/6/2019 Chapter 4 Memory Management-part1
28/28
Registers Used during
Execution
a relative address to produce an absolute
The resulting address is compared with
If the address is not within bounds, an
n errup s genera e o e opera ngsystem
Top Related