Memory Managment
Memory Managment
User User
RAM Prog RAM User RAM Prog
Prog
OS OS
Basics of memory management
Multiprogramming
• Although the following simple memory
management techniques are not used in
modern OS, they lay the ground for a
proper discussion of virtual memory
– fixed partitioning
– dynamic partitioning
– simple paging
– simple segmentation
Basics of memory management
Fixed Partitioning
• Partition main
memory into a set of
non overlapping
regions called
partitions
• Partitions can be of
equal or unequal
sizes
Basics of memory management
Equal-sized fixed partitions
• Any program, no matter how small, occupies an
entire partition.
• If there is an available partition, a process can
be loaded into that partition
• because all partitions are of equal size, it does not matter
which partition is used
• If all partitions are occupied by blocked
processes, choose one process to swap out to
make room for the new process
• Main memory use is inefficient.
– This is called internal fragmentation.
Basics of memory management
Unequal-sized fixed partitions
• Any process whose size is less than or equal to
a partition size can be loaded into the partition
• If all partitions are occupied, the operating
system can swap a process out of a partition
• Two types:
– Using multiple queue
– Using single queue
• Multiple queue
– When a job arrives, it can be put into the input queue
for the smallest partition large enough to hold it
– Problem
• the queue for a large partition is empty but the
queue for a small partition is full
Basics of memory management
Unequal-sized fixed partitions
Partion 4
• Assign each process to 900k
the smallest partition Partion 3
within which it will fit
500k
• A queue for each
Partion 2
partition size tries to
300k
minimize internal Partion 1
200k
fragmentation
OS
Basics of memory management
Unequal-sized fixed partitions
• Single queue
– maintain a single queue and whenever a partition
becomes free, the job closest to the front of the queue
that fits in it could be loaded into the empty partition
and run
– Problem
• waste a large partition on a small job
– Solution
• search the whole input queue whenever a partition becomes
free and pick the largest job that fits
• But this algorithm discriminates against small jobs as being
unworthy of having a whole partition, whereas usually it is
desirable to give the smallest jobs (often interactive jobs) the
best service, not the worst.
Basics of memory management
Unequal-sized fixed partitions
• Single queue
– Ways to allow small jobs
• To have at least one small partition around.
– Such a partition will allow small jobs to run
without having to allocate a large partition for
them
• Another approach is to have a rule stating
that a job that is eligible to run may not be
skipped over more than k times.
– Each time it is skipped over, it gets one point.
When it has acquired k points, it may not be
skipped again.
Basics of memory management
Unequal-sized fixed partitions
Basics of memory management
Dynamic Partitioning
• Partitions are of variable length and number
• Each process is allocated exactly as much
memory as it requires
• Eventually holes are formed in main memory.
– This is called external fragmentation
• Must use compaction to shift processes so
they are contiguous and all free memory is in
one block
• Used in IBM’s OS/MVT (Multiprogramming with
a Variable number of Tasks)
Basics of memory management
Dynamic Partitioning