Professional Documents
Culture Documents
MSJ-2
External Fragmentation
MSJ-3
External Fragmentation with Best Fit
main
memory
• Note that just because process #8 can’t be
Let’s • see
OS
admitted, how best-fit
processes,
that doesn’tbeing
works
meanthe onfirst
some
that ones created,
random
another series of OS and
arrivals
• When Because
process
are usually we’re
#1
placed doing
terminates,
atofone best-fit,
endits memory
ofsizes
the is processes
terminations
(smaller)
reclaimed of processes
process can’t still random
be admitted,
But process
memory,
memory • is #4
Process
with went
still
low #2 into the being
terminates
fragmented,
memory meaningProcess
smallest the #4 process #9
process #1
#4
provided there’s
• First,
available
the a hole
hole
FSL big
thatmay
must enough
wassearched
be large terminates
enough
to see if process
that
• •But
most
some
As there’s
new •
noIt’s
common
new memory
processes
choice
guarantee
processes are is
that
created, reclaimed
not
there
be
theywillmustand be admitted byprocess #7
admitted, there are
despiteanytheadjacent
factlow thatholes
there it can
is,checkbe
inthe
the
ever • Our
long
again term
be merged
textbook
a shows
scheduler
hole with
big the
which
enough hole
memory
must
for above at it with the
total, merged
enough with (inmemory
unused this case, forno)
them process #8 process #2
processtop
memory of
#8; its figures,
manager
starvation addresses
to see
is increasing as
if there is sufficient space for
possible
the one• Then
new moves the down
process new hole is inserted
the picture, so inI’llthe
doFSLthe
• same thingmanager
in this diagram process process #6
• When process #8 applies
The memory searches
When forprocess theProcess
admission, free #3
space
#6 terminates,
#10
list (FSL)process #3
to find a hole
memory has become too that is of sufficient
process terminates
size
#8 can be admitted
fragmented
• •The
Thissum animation
total of illustrates
all free space “best-fit”
is moreFSL thanlogic
the process #8 demand, but a process needs process #5
its physical address space to be contiguous
and there is no single (contiguous) hole big
enough to admit process #8
MSJ-4
External Fragmentation with Worst-Fit
main
memory
OS
Let’s look at the same sequence of arrivals and processes
terminations as for the previous best-fit example,
but let’s see what happened if we do worst-fit for process #1
our FSL
process #2
process #6
#3
process #8 process #4
process #7
process #5
process #9
MSJ-5
Summary of FSL Policies for
Contiguous Memory Management
MSJ-7
Internal Fragmentation
(and Then Quantized Allocation)
MSJ-8
Quantized Allocation
MSJ-9
Quantized Allocation (cont’d)
MSJ-10
Internal Fragmentation Again
Maybe, but …
MSJ-11
Average Internal Fragmentation
MSJ-12
So What’s the Answer?
MSJ-13
Compaction
MSJ-14
Compaction
main
memory
To compact memory is to relocate processes so OS
processes
as to consolidate all the holes into one big hole
to make room for a new process that otherwise
couldn’t be admitted because of external
process #7
fragmentation
Compaction can be total, as we just saw, whereprocess #8
every process not already “snug at the end” gets
process #6
relocated, or …
process #5
MSJ-15
Compaction (cont’d)
main
memory
It can be “partial”: Just relocate enough OS
processes
processes to make a hole big enough for
the new process, don’t consolidate all
the holes (unless necessary)
process #7
There are several issues to consider in
either case process #8
process #6
process #5
MSJ-16
Compaction Requires Execution Time Binding
Which Requires an MMU Extra Hardware
main
memory
The address 0x00f32 here can’t be a OS
physical address or it would behave
incorrect processes
If this were a physical address, it would to
have beenafter theearlier
bound relocation ofatprocess
i.e., #7or
compile and the
load timeOS would
and have no
we can’t wayittonow:
rebind correct it
process #7
• We obviously can’t recompile a process in 0x2a00f32
So the middle
if the OS isof it’s execution
going to have to dynamically
• And the
relocate execution
a process Here’s itsour old friend,
environment
during doesn’t
execution, someissort
which
what compaction
include of jump
requires,
the relocation or addresses
the
flags transfer
used by instruction
in the
the process #6
programs
loader atin load
memory they’re
timehave to be left behind in
logical
addresses
the loadand we must
module be doing
on the disk execution time
binding, which requires an MMU
process #5
MSJ-17
Other Issues with Compaction
main
memory
OS
Physically copying all the processes in memory to processes
new locations is generally going to be too time-
consuming for a real-time system
process #7
process #6
process #5
MSJ-18
Other Issues with Compaction (cont’d)
main
memory
MSJ-20