Contiguous Memory Allocation
Contiguous Memory Allocation
processes are allotted a continuous block of space in memory. This block can be of
fixed size for all the processes in a fixed size partition scheme or can be of variable
size depending on the requirements of the process in a variable size partition scheme.
1. Because all of the blocks are the same size, this scheme is simple to implement.
All we have to do now is divide the memory into fixed blocks and assign
processes to them.
2. It is easy to keep track of how many blocks of memory are left, which in turn
decides how many more processes can be given space in the memory.
3. As at a time multiple processes can be kept in the memory, this scheme can be
implemented in a system that needs multiprogramming.
Disadvantages
1. As the size of the blocks is fixed, we will not be able to allot space to a process
that has a greater size than the block.
2. The size of the blocks decides the degree of multiprogramming, and only that
many processes can remain in the memory at once as the number of blocks.
3. If the size of the block is greater than the size of the process, we have no other
choice but to assign the process to this block, but this will lead to much empty
space left behind in the block. This empty space could've been used to
accommodate a different process. This is called internal fragmentation. Hence,
this technique may lead to space wastage.
Disdvantages
Though the variable-size partition scheme has many advantages, it also has some
disadvantages:
First-Fit
This is a very basic strategy in which we start from the beginning and allot the first
hole, which is big enough as per the requirements of the process. The first-fit strategy
can also be implemented in a way where we can start our search for the first-fit hole
from the place we left off last time.
Best-Fit
This is a greedy strategy that aims to reduce any memory wasted because of internal
fragmentation in the case of static partitioning, and hence we allot that hole to the
process, which is the smallest hole that fits the requirements of the process. Hence, we
need to first sort the holes according to their sizes and pick the best fit for the process
without wasting memory.
Worst-Fit
This strategy is the opposite of the Best-Fit strategy. We sort the holes according to
their sizes and choose the largest hole to be allotted to the incoming process. The idea
behind this allocation is that as the process is allotted a large hole, it will have a lot of
space left behind as internal fragmentation. Hence, this will create a hole that will be
large enough to accommodate a few other processes.
Example :
It is of five types:
It is of two types: 1. Paging
9. 2. Multilevel Paging
1. Fixed(or static) partitioning
3. Inverted Paging
2. Dynamic partitioning
4. Segmentation
5. Segmented Paging