Memory Management

bahamanomniscientDéveloppement de logiciels

14 déc. 2013 (il y a 3 années et 3 mois)

194 vue(s)

Memory Management


Main Memory


CPU Registers

Speed and

OS Memory Manager

Keeps track of which parts of memory
are in use, allocation/deallocation of
memory to/from processes and
swapping processes between the
various levels of the memory hierarchy.

Memory Management Systems

Two Class of Systems

Those that shuffle processes between main
memory and disk during execution

…and those that do not.

Basic Memory Management:
Running one program at a time

These models are rarely used any more. Why?

Multiprogramming with Fixed

What if we would like to have more
than one program loaded up in

Obviously we need to ensure that one
process is separated (partitioned) from
another process in memory.

Examples of Fixed Memory

What happens if we have
a small job and only a big
partition available?

Queue for large partition
is empty. Small may be

CPU Usage using

Degree of multiprogramming

CPU Utilization = 1


n = number of processes

p = fraction of time processes wait

on I/O

Multiprogramming Memory

Where will the program be loaded into

How will a program be protected from
other programs maliciously writing to it?


When a program is linked (library files,
initialized data, uninitilized data, etc.) placed
into a single address space it needs to know
where it will eventually reside in memory.

Obviously an offset can be added to the
instruction addresses letting the program
know where things are located on a relative


Just because we can properly locate a
program in memory does not mean it is

Different mechanisms for protection

protection codes stored in Status Register

Base (start of partition) and Limit (length
of partition) Registers actually addresses
the relocation and protection issue at the
same time.

Not enough memory for Active
Process? What do we do?

Swap the processes from disk to main

How much memory should be
allocated to a process?

Will the process be static in memory size over
the course of the processes life?

Easy, allocate what is required

Will the process be dynamic in memory size
over the course of the processes life?

Allocate room to grow in the beginning

Other processes may have to swapped to disk

How might the OS manage
dynamic allocation?


indicating which parts of
memory are free with a 0 or 1 marking
some unit of memory as free or
occupied respectively.

Searching a bitmap for a specified size
of free memory can be a slow

Memory with Five Processes
and Three Holes


Linked List


How might the OS manage
dynamic allocation? (cont.)

Linked List

Maintain a linked list
where each segment in the list is either
a process or a hole between processes.

Segment list is kept sorted by address.
This allows for the list to be updating
easily upon a process being terminated
or swapped.

Four Scenarios for combining
memory after Terminating a Process

Using Address Ordered Linked Lists to recombine

memory segments upon process termination.

How do we allocate memory for a
new process with address ordered
linked lists?

First Fit

First hole that works is the one it uses.

Next Fit

Remembers the location of the hole and
starts there upon successive iterations (slightly worse
performance than first fit)

Best Fit

Searches entire list for “best fit” (Obviously
slow, but also wastes more memory than next and
first fit… why?)

Worst Fit

Find the biggest hole

All algorithms can be speeded up if processes and
holes are kept on separate lists.

This is obviously done at a cost of increased complexity and
slowdown upon deallocation. Why?

Memory with Five Processes
and Three Holes


Linked List