Fixed vs Variable Partitioning

2
0

Introduction

Contiguous memory allocation needs a policy for deciding how physical RAM should be divided among processes. The operating system must choose whether memory should be split before processes arrive or divided dynamically as processes request space.

Fixed partitioning and variable partitioning are two basic approaches. Fixed partitioning creates predefined memory blocks, while variable partitioning creates blocks according to process requirements.

Fixed Partitioning

Fixed partitioning divides memory into fixed-size partitions in advance. These partitions are created before process requests arrive, and their sizes do not change during allocation.

When a process arrives, the OS searches for a partition large enough to hold it. If a suitable partition is available, the entire partition is assigned to that process.

This method is simple because memory structure is already decided. However, the fixed size of each partition can waste memory.

Internal Fragmentation

Internal fragmentation occurs when unused space remains inside an allocated partition.

Suppose a process requires 35 KB, and the closest available fixed partition is 50 KB. The OS allocates the full 50 KB partition because it cannot shrink the partition.

The wasted space is: Internal fragmentation = 50 KB - 35 KB = 15 KB

This 15 KB is inside an allocated partition, so another process cannot use it. That is why fixed partitioning is strongly associated with internal fragmentation.

Fixed Partitioning & Internal Fragmentation

Fixed Partitioning & Internal Fragmentation

Variable Partitioning

Variable partitioning creates partitions dynamically when processes request memory. Instead of dividing RAM into fixed blocks beforehand, the OS creates a partition based on the size needed by the incoming process.

For example, suppose a free block of 600 KB is available and a process requests 220 KB. The OS can allocate 220 KB to the process and leave the remaining 380 KB as free space.

This makes variable partitioning more flexible than fixed partitioning because the allocated block can match the process size more closely.

Benefits of Variable Partitioning

Variable partitioning reduces the direct internal waste seen in fixed partitioning.

  • Better size matching: The partition can be created according to the process request.

  • Less internal waste: The OS does not have to allocate a large predefined partition when a smaller one is enough.

  • Flexible allocation: Partition sizes are decided during allocation, not fixed in advance.

This flexibility is useful, but it introduces another problem: free memory can become scattered over time.

Variable Partitioning

Variable Partitioning

External Fragmentation

External fragmentation occurs when free memory exists, but it is split into separate holes instead of being available as one continuous block.

Suppose free memory is available in four holes:

Hole 1

Hole 2

Hole 3

Hole 4

20 KB

40 KB

30 KB

25 KB

The total free memory is 20 KB + 40 KB + 30 KB + 25 KB = 115 KB.

If a new process requests 100 KB, the request still fails because no single hole is large enough. The memory exists in total, but it is scattered.

This is the central problem of variable partitioning: it can avoid much internal waste, but it can create external fragmentation.

External Fragmentation

External Fragmentation

Why Holes Appear

Holes appear because processes do not always finish in the same order in which they were allocated.

A process in the middle of memory may finish while neighboring processes continue running. Its old memory region becomes free, but that free space is trapped between allocated regions.

As more processes finish, more scattered holes may appear. Neighboring free holes can be merged, but separated holes cannot be treated as one continuous physical block unless compaction or another memory strategy is used.

Fixed vs Variable Partitioning

Feature

Fixed Partitioning

Variable Partitioning

Partition creation

Divided in advance

Created when a process requests memory

Partition size

Fixed

Depends on process requirement

Simplicity

Simpler to manage

More flexible but more complex

Main waste

Internal fragmentation

External fragmentation

Active process limit

Limited by number of partitions

Depends on available free holes

The key difference is where the unused space appears. Fixed partitioning wastes space inside allocated partitions, while variable partitioning can leave scattered free holes between allocations.

Compact Worked Examples

For fixed partitioning, suppose partitions are 100 KB, 250 KB, 400 KB, and 600 KB.

Process

Size

Assigned Partition

Internal Fragmentation

P1

90 KB

100 KB

10 KB

P2

220 KB

250 KB

30 KB

P3

390 KB

400 KB

10 KB

Total internal fragmentation is 10 KB + 30 KB + 10 KB = 50 KB.

For variable partitioning, suppose free holes are 100 KB, 150 KB, and 200 KB. Total free memory is 450 KB, but a 300 KB process cannot be allocated because the largest single hole is only 200 KB.

Summary

Fixed partitioning divides RAM into predefined partitions before process allocation. It is simple, but it can waste memory inside allocated partitions, causing internal fragmentation.

Variable partitioning creates partitions dynamically based on process size. It uses memory more flexibly, but over time it can create scattered free holes, causing external fragmentation.

CS Core

Read Similar Blogs

Comments0