Dynamic Partitioning

Dynamic partitioning is also known as variable partitioning. It eliminates the factor of internal fragmentation. In this technique, the partition’s sizes are declared at the loading time of the process. It does not have a predefined memory partition.

OS itself loads in the first partition. The remaining space is divided into different parts. These parts are known as partitions. Every partition size will be equal to the size of the incoming process. So, partition sizes are not similar.

Dynamic partitioning Example

The dynamic partition will never have internal fragmentation, but external fragmentation may exist, as explained in the diagram below.

Dynamic partitions external fragmentation

2MB of unused space in Partition 2 and 1MB of unused space in Partition 4 leads toward external fragmentation because P8, with a size of 3MB, can’t load. Therefore, we can say this unused space is external fragmentation.

It is not an internal fragmentation because the size of 2MB can be accommodated in partition 2.

Conditions for Dynamic Partitions

We know the partitions are allocated to process at run time, and there is no problem with partition size, but the condition is

1. One process cannot reside in more than one partition. (spanning not allowed)

Explain: As there are two empty partitions of 1MB and 4MB in RAM, and the incoming process size is 5MB, the Main memory can’t accommodate it.

Dynamic partitioning Conditions

Advantages of Dynamic Partitioning over Fixed Partitioning

1. No Internal Fragmentation

As process size is always equal to partition size, then there will be no internal fragmentation.

2. No Limitation of process size

As partition size is declared at loading time. So, there is no limitation on process size.

3. Degree of multi-programming is dynamic

Due to the absence of internal fragmentation, more processes can be loaded into the memory at a time

Disadvantages of dynamic partitioning

1. External Fragmentation

If there is no internal fragmentation, then it doesn’t mean that there will not be external fragmentation.

Let’s consider there are four processes: P1 (2 MB), P2 (6 MB), P3 (3 MB), P4 (4 MB) and P5 (6 MB). These are loaded in the main memory’s respective partitions 1, 2, 3, 4, and 5.

After some time, Process 2 and P4 are completed, and their assigned space is free. Now, two free-space partitions (6 MB and 4 MB) are available in the main memory after loading P6 and P7 in partitions 2 and 4, respectively. There is still free space of 2MB and 1MB in partitions 2 and 4, respectively. But this free space cannot load the process 8 of 3 MB into the memory. This is because the free space exists at different main memory locations.

That’s why this 3MB free space leads toward external fragmentation. As shown in the following diagram,

Variable-partitions--external-fragmentation