0% found this document useful (0 votes)
12 views

Contiguous Memory Allocation

Uploaded by

VVM
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Contiguous Memory Allocation

Uploaded by

VVM
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Contiguous Memory Allocation is a type of memory allocation technique where

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.

Contiguous Memory Allocation Techniques

This allocation can be done in two ways:

1. Fixed-size Partition Scheme


2. Variable-size Partition Scheme

Fixed-size Partition Scheme

In this type of contiguous memory allocation technique, each process is allotted a


fixed size continuous block in the main memory. That means there will be
continuous blocks of fixed size into which the complete memory will be divided, and
each time a process comes in, it will be allotted one of the free blocks. Because
irrespective of the size of the process, each is allotted a block of the same size
memory space. This technique is also called static partitioning.
Advantages

The advantages of a fixed-size partition scheme are:

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.

Variable-size Partition Scheme

In this type of contiguous memory allocation technique, no fixed blocks or partitions


are made in the memory. Instead, each process is allotted a variable-sized block
depending upon its requirements. That means, whenever a new process wants some
space in the memory, if available, this amount of space is allotted to it. Hence, the size
of each block depends on the size and requirements of the process which occupies it.
Advantages

The advantages of a variable-size partition scheme are:

1. As the processes have blocks of space allotted to them as per their


requirements, there is no internal fragmentation. Hence, there is no memory
wastage in this scheme.
2. The number of processes that can be in the memory at once will depend upon
how many processes are in the memory and how much space they occupy.
Hence, it will be different for different cases and will be dynamic.
3. As there are no blocks that are of fixed size, even a process of big size can be
allotted space.

Disdvantages

Though the variable-size partition scheme has many advantages, it also has some
disadvantages:

1. Because this approach is dynamic, a variable-size partition scheme is difficult


to implement.
2. It is difficult to keep track of processes and the remaining space in the memory.

Strategies Used for Contiguous Memory Allocation Input Queues

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 :

<CLASS WORK EXAMPLE NEED TO WRITE HERE>

Difference between Contiguous and Non-contiguous


Memory Allocation:
(5 Marks)
S.NO. Contiguous Memory Allocation Non-Contiguous Memory Allocation

Contiguous memory allocation Non-Contiguous memory allocation


1. allocates consecutive blocks of memory allocates separate blocks of memory to a
to a file/process. file/process.

2. Faster in Execution. Slower in Execution.

3. It is easier for the OS to control. It is difficult for the OS to control.

Overhead is minimum as not much


More Overheads are there as there are
4. address translations are there while
more address translations.
executing a process.

Both Internal fragmentation and Only External fragmentation occurs in


5. external fragmentation occurs in Non-Contiguous memory allocation
Contiguous memory allocation method. method.

It includes single partition allocation


6. It includes paging and segmentation.
and multi-partition allocation.

7. Wastage of memory is there. No memory wastage is there.

In contiguous memory allocation, In non-contiguous memory allocation,


8. swapped-in processes are arranged in swapped-in processes can be arranged in
the originally allocated space. any place in the memory.

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

It could be visualized and implemented It could be implemented using Linked


10.
using Arrays. Lists.

Degree of multiprogramming is fixed as


11. Degree of multiprogramming is not fixed
fixed partitions

You might also like