Lecture 14 Memory Management II

advertisement
Lecture 14
Memory Management II
Contiguous Allocation
Fall 2000
M.B. Ibáñez
Single-Partition Allocation
Memory
0
Operating
System
Process 1
Process 2
512K
Fall 2000
M.B. Ibáñez
Single-Partition Allocation
Hardware Support I
Memory
0
Operating
System
100K
base register
100K
Process 1
100K
limit register
200K
512K
Fall 2000
M.B. Ibáñez
Single-Partition Allocation
Hardware Support II
Limit
register
CPU
<
+
Trap
Addressing error
Fall 2000
Relocation
register
M.B. Ibáñez
Memory
Multiple-partition Allocation
Fixed Partitioning I
• Main memory is divided into a number of
static partitions at system generation time.
• A process may be loaded into a partition of
equal or smaller size.
• Simple to implement
• Little operating system overhead
Fall 2000
M.B. Ibáñez
Multiple-partition Allocation
Fixed Partitioning II
Operating System
8M
Operating System
8M
6M
8M
8M
8M
8M
8M
Fall 2000
12 M
M.B. Ibáñez
Placement Algorithm with Partitions
Equal size partitions
• Because all partitions are of equal size, it does not
matter which partition is used
• If all partitions are occupied with processes that
are not ready to run, then one of these processes
must be swapped out to make room for a new
process.
Fall 2000
M.B. Ibáñez
Difficulties of equal-size
partitions
• A program may be too big to fit into a
partition. In this case, the programmer must
use the overlay technique.
• Internal fragmentation
– Wasted space internal to a partition. Any
program, no matter how small, occupies an
entire partition.
Fall 2000
M.B. Ibáñez
Placement Algorithm with Partitions
Unequal-size partitions
• Best-fit
– can assign each process to the smallest partition within
which it will fit
– queue for each partition
– processes are assigned in such a way as to minimize
wasted memory within a partition
Fall 2000
M.B. Ibáñez
Placement Algorithm with Partitions
Unequal-size partitions
• First-fit
– Allocate the first hole that is big enough.
• Neither first-fit nor best-fit is clearly better
in terms of storage utilization, but first-fit is
generally faster
Fall 2000
M.B. Ibáñez
Difficulties with Unequal-size partitions
• The number of partitions specified at
system generation time limits the number of
active (not suspended) processes in the
system
• Small jobs will not utilize partition space
efficiently
Fall 2000
M.B. Ibáñez
One Process Queue per Partition
Operating
System
New
Processes
Fall 2000
M.B. Ibáñez
One Process Queue per Partition
Operating
System
New
Processes
Fall 2000
M.B. Ibáñez
Download