Chapter 5
Memory Management
Subtitle
Learning Objectives
At the end of this lesson you will be able to:
• Define Memory Management
• Understand the static partitioning
• Understand dynamic partitioning
• Know the advantages and disadvantages of static partitioning
• Know the advantages and disadvantages of dynamic partitioning
Introduction
Memory Management is the method or a functionality of an operating
system which handles or manages primary memory. It is the process of
controlling and coordinating computer memory, assigning portions called
blocks to various running programs to optimize overall system
performance.
The memory management function keeps track of the status of each
memory location, either allocated or free. It determines how memory is
allocated among competing processes, deciding which gets memory, when
they receive it, and how much they are allowed.
Allocation of memory simply means providing an individual space for
individual data or files. For example, if F is a file, the system will allot a
certain address at which this F-named file will be stored
Memory Management
• Memory management is the • It decides which process will get
functionality of an operating memory at what time.
system which handles or manages • It tracks whenever some memory
primary memory and moves gets freed or unallocated and
processes back and forth between correspondingly it updates the
main memory and disk during status.
execution.
• Memory management keeps track
of each and every memory location,
regardless of either it is allocated to
some process or it is free.
• It checks how much memory is to
be allocated to processes.
There are two Memory Management
Techniques:
• There is Contiguous, and Non-Contiguous Memory
Management Techniques.
Contiguous, and Non-Contiguous Memory Management
• In Contiguous Technique, Memory is allocated into continuous
manner. If the process need 10 space of memory (10 space of
memory is available at one place.
• All the available memory space remain together in one place.
• both the operating system and the user must reside in the main
memory. The main memory is divided into two portions one portion is
for the operating and other is for the user program.
Non-contiguous Memory
• Non-contiguous memory allocation the available free memory space
are scattered here and there and all the free memory space is not at
one place.
• In the non-contiguous memory allocation, a process will acquire the
memory space but it is not at one place it is at the different locations
according to the process requirement.
• If the process need 10 memory of space 5MB is allocated at some
place and another 5MB is allocated at some other place.
Contiguous Technique can be divided into:
Contiguous Technique can be divided into:
• Fixed (or static) partitioning
• Variable (or dynamic) partitioning
Fixed (or static) partitioning
• This is the oldest and simplest
technique used to put more than
one processes in the main
memory. In this partitioning,
number of partitions (non-
overlapping) in RAM are fixed but
size of each partition may or may
not be same.
• 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
OS can swap a process out of a
partition.
Illustrate the above figure
• As illustrated in above figure, first process is only consuming 1MB out of
4MB in the main memory.
• Hence, Internal Fragmentation in first block is (4-1) = 3MB.
• Sum of Internal Fragmentation in every block = (4-1)+(8-7)+(8-7)+(16-
14)= 3+1+1+2 = 7MB.
• Suppose process P5 of size 7MB comes. But this process cannot be
accommodated in spite of available free space because of contiguous
allocation (as spanning is not allowed). Hence, 7MB becomes part of
External Fragmentation.
Advantages of Fixed Partitioning :
• Easy to implement:
• Algorithms needed to implement Fixed Partitioning are easy to
implement. It simply requires putting a process into a certain partition
without focusing on the emergence of Internal and External
Fragmentation.
• Little OS overhead
• Processing of Fixed Partitioning requires lesser excess power.
Disadvantages of Fixed Partitioning
• External Fragmentation: The total unused space (as stated above) of various
partitions cannot be used to load the processes even though there is space
available but not in the contiguous form (as spanning is not allowed).
• Internal Fragmentation: Main memory use is inefficient. Any program, no matter
how small, occupies an entire partition. This can cause internal fragmentation.
• Limit process size: Process of size greater than the size of the partition in Main
Memory cannot be accommodated. The partition size cannot be varied according
to the size of the incoming process size. Hence, the process size of 32MB in the
above-stated example is invalid.
• Limitation on Degree of Multiprogramming: Partitions in Main Memory are
made before execution or during system configure. Main Memory is divided into
a fixed number of partitions
Variable (or dynamic) partitioning
• To overcome some of the problems
associated with fixed partitioning, an
approach known as dynamic
partitioning was developed.
• Partitions are created dynamically
(each process is loaded into a
partition of exactly the same size of
that process).
Dynamic Partition
• The figures on the next page illustrate a dynamic partitioning example, using
64 MB of memory.
• In figure (a), main memory is initially empty, except for the OS.
• In figures (b), (c), and (d), the first three processes are loaded, starting where
the OS ends and occupying just enough space for each process. This leaves
a “hole” at the end of memory which is too small for a fourth process.
• At some point in time (figure (e)) the OS swaps out process 2, which leaves
enough room to load another process, process 4 as shown in figure (f).
• Since process 4 is smaller than process 2, another smaller hole is created.
• Later, a point is reached when none of the processes in main memory are
ready, but process 2, in the ready/suspend state, is available. However, since
there is insufficient room for process 2, the OS swaps out process 1 (figure
(g)) and swaps process 2 back in (figure (h)).
Advantages of Variable/Dynamic Partitioning
• No Internal Fragmentation: In variable Partitioning, space in main memory
is allocated strictly according to the need of process, hence there is no
case of internal fragmentation. There will be no unused space left in the
partition.
• No restriction on Degree of Multiprogramming: More number of
processes can be accommodated due to absence of internal
fragmentation. A process can be loaded until the memory is empty.
• No Limitation on the size of the process: In Fixed partitioning, the process
with the size greater than the size of the largest partition could not be
loaded and process can not be divided as it is invalid in contiguous
allocation technique. Here, In variable partitioning, the process size can’t
be restricted since the partition size is decided according to the process
size.
Disadvantages of Variable/Dynamic Partitioning
• Difficult Implementation: Implementing variable partitioning is
difficult as compared to fixed partitioning as it involves allocation of
memory during run-time rather than during system configure.
• External fragmentation: There will be external fragmentation in spite
of absence of internal fragmentation.
END