
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















CompSci 143A
Spring, 2009
Spring, 2009
CompSci 143A
Spring, 2009
CompSci 143A
Figure 7-2Spring, 2009
pa = address_map(la)
address_map
:
R l
ti
R
i t
l^
R
elocation Register:
pa = la + RR
More general form:
More
general form: Page/Segment Table
(Chapter 8)
CompSci 143A
Spring, 2009
-^
Fixed Partitions– Single-program systems: 2 partitions (OS/user)
Single program systems: 2 partitions (OS/user)
How to assign processes to partitions
(cf. Fig 7-5)
be unused
Limitations of fixed partitions– Program size limited to largest partition
g
g
p
CompSci 143A
Spring, 2009
-^
Memory not partitioned
a priori
-^
Each request is allocated portion of free space
-^
Memory = Sequence of variable-size blocks– Some are occupied, some are free (holes)
E t
l f
t ti
b
xternal fragmentation
occurs: memory may be
divided into many small pieces
-^
Adjacent holes (right, left, or both) must be
j^
(^
g
,^
,^
)
coalesced
to prevent increasing fragmentation
CompSci 143A
Figure 7-
Spring, 2009
-^
-^
-^
Must be sorted by physical address
-^
b
b
’s right,
follow its predecessor link to first hole on
b
’s left, and check if it is
p^
,
adjacent to
b
.
CompSci 143A
Figure 7-7a
Spring, 2009
&
and
|
'
CompSci 143A
Spring, 2009
A
3 KB
Free
i d
B
2 KB
Occupied
C
5 KB
Occupied
D
1 KB
Occupied
E
5 KB
Free
E
5 KB
Free
B[1] = B[1] & '11011111'
00011111
11100000
B[0] = B[0] | '11000000'
Spring, 2009
Figure 7-
Sizes: 1, 2, 4, 8, 16 a)
3 blocks allocated& 3 holes left
b)
Block of size 1allocatedallocated
c)
Block 12-13 released
CompSci 143A
Spring, 2009
Allocation Strategies with Variable Partitions
-^
Problem: Given a request for
n
bytes, find hole
≥
n
-^
Goals:
-^
Goals:^ – Maximize memory utilization (minimize
external
fragmentation
Search Strategies:–
First-fit:
Always start at same place. Simplest.
Next-fit:
Resume search. Improves distribution of holes.
est-fit:
Closest fit. Avoid breaking up large holes.
Worst-fit:
Largest fit. Avoid leaving tiny hole fragments
Fi
t Fit i
ll
th
b
t^
h i
CompSci 143A
-^
First Fit is generally the best choice
Spring, 2009
-^
How many blocks are used, how many are holes?–
% rule
(Knuth, 1968):
rule
(Knuth,
#holes = p × #full_blocks/
= probability of inexact match (i.e., remaining hole)
I^
i^
1
p=
, because exact matches are highly unlikely, so
1/3 are holes
CompSci 143A
Spring, 2009
-^
Utilization depends on the ratio
k=hole_size/block_size
Wh
1
(
i^
b bili
f i
h)
-^
When
p=
(
p
i
s probability of inexact match)
unused_memory = k/(k+2)
-^
Intuition:Intuition:– When
k
unused_memory
(100% empty)
k=
unused_memory
(50% rule)
Wh
k
d
(100% f ll)
k
unused_memory
full)
-^
What determines
k
?
The block size
b
relative to total memory size
M
y
b
≤^
M/
,^
k=0.
and
unused_memory
≈0.
b=M/
,^
k=
and
unused memory
≈0.
CompSci 143A
,^
_^
y
Conclusion:
M
must be large relative to
b
Spring, 2009