Fixed vs Variable Partitioning in OS: Memory Allocation & Protection Explained

OPERATING SYSTEM - CHAPTER 21

Fixed vs Variable Partitioning in OS: Memory Allocation and Protection Explained

Imagine that your computer has one large room called main memory. Many programs want to enter this room, but every program needs a different amount of space. The operating system therefore needs a method to divide memory and decide where each process should stay.

Two early and important techniques used for this purpose are Fixed Partitioning and Variable Partitioning. These ideas also help us understand memory allocation, fragmentation, compaction and memory protection.

Quick Answer:

Fixed Partitioning divides main memory into predefined partitions. A process is placed inside one available partition. Because a process may be smaller than its partition, some memory can remain unused inside the partition. This is called internal fragmentation.

Variable Partitioning creates a partition according to the size required by a process. It reduces internal waste, but after many processes enter and leave memory, free memory can become scattered. This is called external fragmentation.

What Is Memory Partitioning in Operating System?

Fixed vs Variable Partitioning in OS: Memory Allocation & Protection Explained

Main memory is limited. At the same time, several processes may need to stay in memory so that the CPU can execute them.

One simple way to organize memory is to divide it into separate areas. These areas are called partitions.

Simple Definition:
Memory partitioning is a technique in which main memory is divided into separate regions so that different processes can be placed in different memory areas.

Why Is Partitioning Needed?

1
Store Multiple Processes Several processes can stay in main memory at the same time.
2
Use Memory Systematically The operating system knows which memory area belongs to which process.
3
Protect Processes One process should not be allowed to overwrite another process.
4
Track Free Space The operating system can identify which areas are available.
5
Support Multiprogramming Many jobs can remain ready in memory.
6
Improve CPU Usage Another process can run when one process waits for input or output.

Basic Main Memory Layout

The operating system itself occupies some part of RAM. The remaining memory can be used for user processes.

MAIN MEMORY VISUAL
Operating System
Process P1
Process P2
Process P3
Free Memory

The main question is: how should the operating system create these process areas?

Two important answers are:

  • Fixed Partitioning
  • Variable Partitioning

What Is Fixed Partitioning in OS?

In Fixed Partitioning, main memory is divided into a fixed number of partitions before processes are loaded.

These partitions remain predefined while the system is working.

Easy Definition:
Fixed Partitioning is a contiguous memory allocation technique in which main memory is divided into a fixed number of predefined partitions and each process is loaded into one suitable free partition.
FIXED PARTITION MEMORY
Operating System - 128 KB
Partition 1 - 224 KB
Partition 2 - 224 KB
Partition 3 - 224 KB
Partition 4 - 224 KB

How Fixed Partitioning Works

  1. Main memory is divided into predefined partitions.
  2. A process arrives.
  3. The operating system checks available partitions.
  4. A suitable partition is selected.
  5. The process is loaded into that partition.
  6. When the process finishes, that partition becomes free again.

Types of Fixed Partitioning

Equal Size Partitions

Every partition has the same size.

Partition 1 = 200 KB Partition 2 = 200 KB Partition 3 = 200 KB Partition 4 = 200 KB

This is simple to manage, but a process larger than one partition cannot be loaded even if total free memory is sufficient.

Unequal Size Partitions

Different partitions have different sizes.

Partition 1 = 100 KB Partition 2 = 200 KB Partition 3 = 300 KB Partition 4 = 400 KB

This provides more flexibility because small processes can use small partitions and larger processes can use larger partitions.

Fixed Partitioning Example

Suppose a computer has 1024 KB RAM.

The operating system uses 128 KB.

Total RAM = 1024 KB Operating System = 128 KB Memory Left = 1024 - 128 = 896 KB

Suppose the remaining 896 KB is divided into four equal partitions.

896 KB / 4 = 224 KB per partition

Now suppose Process P1 requires only 180 KB.

Partition Size = 224 KB Process Size = 180 KB Unused Space = 224 - 180 = 44 KB

This 44 KB cannot normally be given to another process because it is inside P1's allocated partition.

This unused memory inside the allocated partition is called Internal Fragmentation.

Advantages and Limitations of Fixed Partitioning

1
Simple Easy to understand and implement.
2
Easy Tracking OS only needs to know which predefined partitions are free or occupied.
3
Fast Allocation A free suitable partition can be selected quickly.
Main Limitation:
Fixed partitioning can waste memory because a process may be smaller than the partition assigned to it.
Another limitation is that the number of processes that can stay in memory is limited by the number of partitions.

What Is Variable Partitioning in OS?

Fixed partitioning creates memory areas before processes arrive. Variable partitioning uses a different idea.

Here, a partition is created according to the size required by the arriving process.

Easy Definition:
Variable Partitioning is a contiguous memory allocation technique in which partitions are created dynamically according to the memory requirement of processes.
VARIABLE PARTITION MEMORY
Operating System - 128 KB
P1 - 200 KB
P2 - 150 KB
P3 - 300 KB
P4 - 180 KB
Free - 66 KB

How Variable Partitioning Works

  1. A process arrives.
  2. The operating system checks free memory.
  3. A suitable continuous free area is selected.
  4. A partition is created according to process requirement.
  5. The process is loaded.
  6. When it finishes, its memory area becomes free.

Variable Partitioning Example

Again assume total RAM is 1024 KB and the operating system occupies 128 KB.

Available User Memory = 1024 - 128 = 896 KB

Now four processes arrive:

P1 = 200 KB P2 = 150 KB P3 = 300 KB P4 = 180 KB

Their total requirement is:

200 + 150 + 300 + 180 = 830 KB

Remaining memory:

896 - 830 = 66 KB

Because every partition is created according to process size, there is no large predefined unused area inside each partition.

Fragmentation in Memory Management

Fragmentation means memory becomes wasted or difficult to use efficiently.

There are two main types:

Internal Fragmentation

Unused space exists inside an allocated partition.

Process P1 = 70 KB
Unused = 30 KB
Partition = 100 KB Process = 70 KB Internal Fragmentation = 100 - 70 = 30 KB

This commonly appears in fixed partitioning.

External Fragmentation

Free memory exists, but it is divided into many small holes.

Process P1
Free 20 KB
Process P2
Free 30 KB
Process P3

Total free memory is 50 KB, but it is not one continuous block.

A process requiring 40 KB continuously may fail.

Memory Trick:

Fixed Partitioning = Internal Fragmentation
Variable Partitioning = External Fragmentation

Why Fixed Partitioning Causes Internal Fragmentation

Fixed partitions are created before the operating system knows the exact size of future processes.

Therefore, a process often receives more memory than it actually needs.

Example

Partition Size = 256 KB Process Size = 190 KB

Internal fragmentation:

256 - 190 = 66 KB

66 KB is present inside the partition but is not being used by the process.

Why Variable Partitioning Causes External Fragmentation

In variable partitioning, processes are allocated memory according to their requirements.

But processes do not finish at the same time.

Suppose P2 finishes while P1 and P3 continue running. P2's memory becomes free in the middle.

Later another process may finish somewhere else. Slowly, many small free holes appear at different places in memory.

Even when the total amount of free memory is large, a new process may fail if it requires one continuous block larger than every individual hole.

What Is Compaction?

One possible method for dealing with external fragmentation is compaction.

Compaction moves processes so that multiple small free holes become one large free block.

Before Compaction
Process P1
Free
Process P2
Free
Process P3
Free
→
After Compaction
Process P1
Process P2
Process P3
One Large Free Block
Do not confuse this:
Compaction does not create extra RAM. It only rearranges processes so that existing free memory becomes continuous.
Compaction also has a cost because moving a process may require address relocation and takes processing time.

First Fit, Best Fit and Worst Fit

In variable partitioning, several free holes may exist. The operating system therefore needs a strategy for choosing one hole for a new process.

1
First Fit Select the first available hole that is large enough.
2
Best Fit Select the smallest hole that is still large enough.
3
Worst Fit Select the largest available hole.
Method Selection Rule Search Behaviour Possible Effect
First Fit First suitable hole Can stop once a suitable hole is found Simple and usually fast
Best Fit Smallest suitable hole May require checking many holes Can leave very small unusable holes
Worst Fit Largest available hole Usually needs larger search Leaves a relatively larger remaining hole

First Fit, Best Fit and Worst Fit Solved Example

Available memory holes:

100 KB 500 KB 200 KB 300 KB 600 KB

Process size:

212 KB

First Fit

Start checking from the beginning.

100 KB -> Too Small 500 KB -> Suitable

Therefore:

Selected Hole = 500 KB Remaining = 500 - 212 = 288 KB

Best Fit

Suitable holes:

500 KB 300 KB 600 KB

Smallest suitable hole is 300 KB.

Selected Hole = 300 KB Remaining = 300 - 212 = 88 KB

Worst Fit

Largest hole is 600 KB.

Selected Hole = 600 KB Remaining = 600 - 212 = 388 KB

Try Memory Allocation Yourself

Enter memory holes separated by commas and enter one process size. Then choose First Fit, Best Fit or Worst Fit.

Memory Allocation Calculator

Memory Protection in Partitioned Memory

Memory allocation tells the operating system where a process should stay.

Memory protection answers another important question:

How can the operating system stop a process from accessing memory that does not belong to it?

Suppose P1 and P2 are both loaded in main memory. P1 should not be able to overwrite P2's code or data.

Similarly, a normal user process should not be allowed to modify protected operating-system memory.

MEMORY PROTECTION VISUAL

Logical Address Check

Logical Offset
Example: 650
→
Check
Offset less than Limit
→
Physical Address
Base + Offset

Base Register and Limit Register

Base Register

The base register stores the starting physical address of the process in main memory.

Limit Register

The limit register defines the size of the valid logical address range available to the process.

If the logical offset is smaller than the limit, the address is inside the valid range.
If the logical offset is equal to or greater than the limit, the memory access is outside the allowed range.

Base and Limit Register Solved Example

Base = 4000 Limit = 1000 Logical Offset = 650

First check whether the offset is valid.

650 is smaller than 1000 Therefore: Valid Address

Now calculate the physical address.

Physical Address = Base + Offset = 4000 + 650 = 4650

Important Boundary Case

Base = 4000 Limit = 1000 Offset = 1000

Is offset 1000 valid?

No.

If limit is 1000, valid offsets are: 0 to 999.

Offset 1000 is outside the valid range.

Base-Limit Address Checker

Enter a base address, limit and logical offset.

Memory Protection Calculator

Fixed Partitioning vs Variable Partitioning

Basis Fixed Partitioning Variable Partitioning
Partition Creation Created before processes are loaded Created dynamically when processes arrive
Partition Size Predefined Depends on process requirement
Flexibility Less flexible More flexible
Main Fragmentation Internal fragmentation External fragmentation
Memory Waste Unused space may remain inside partition Free memory may become scattered into holes
Number of Partitions Usually fixed Changes as processes enter and leave
Process Size Process must fit an available predefined partition Partition is created according to process size
Memory Utilization Can be lower because of internal waste Usually better initially
Management Simple More complex
Free Space Tracking Track free predefined partitions Track dynamically changing holes
Compaction Does not solve internal fragmentation Can help reduce external fragmentation
Allocation Algorithms Select suitable predefined partition First Fit, Best Fit and Worst Fit can be used

Common Student Confusions

1. Is all free memory fragmentation?

No. Normal free memory available for future processes is not automatically fragmentation.

Fragmentation refers to memory being wasted or arranged in a form that makes allocation inefficient.

2. Does Variable Partitioning remove all memory waste?

No. It reduces the large internal waste of predefined partitions, but it can create external fragmentation.

3. Does Compaction increase RAM?

No. Compaction only rearranges processes.

4. Are allocation and protection the same?

No.

  • Allocation decides where memory is given.
  • Protection decides which addresses a process is allowed to access.

5. Is Best Fit always the best method?

The word "best" does not mean it is always the best choice in every system. Best Fit specifically means choosing the smallest available hole that can hold the process.

Fixed and Variable Partitioning Exam Preparation

2-Mark Answer

Fixed Partitioning divides main memory into predefined partitions, while Variable Partitioning creates memory partitions dynamically according to the requirements of processes.

Internal Fragmentation Short Answer

Internal fragmentation is unused memory that remains inside an allocated memory block or partition.

External Fragmentation Short Answer

External fragmentation occurs when free memory is divided into several small non-contiguous holes.

For a 5-Mark Question

  1. Define memory partitioning.
  2. Explain Fixed Partitioning.
  3. Explain Variable Partitioning.
  4. Explain internal and external fragmentation.
  5. Write important differences.

For a 10-Mark Question

  1. Meaning of contiguous memory allocation.
  2. Need for partitioning.
  3. Fixed Partitioning.
  4. Equal and unequal fixed partitions.
  5. Fixed partition memory diagram.
  6. Internal fragmentation.
  7. Variable Partitioning.
  8. Variable partition memory diagram.
  9. External fragmentation.
  10. Compaction.
  11. First Fit.
  12. Best Fit.
  13. Worst Fit.
  14. Memory protection.
  15. Base and Limit registers.
  16. Difference between Fixed and Variable Partitioning.

One-Minute Revision

Fixed Partitioning Memory is divided into predefined partitions.
Variable Partitioning Partitions are created according to process size.
Internal Fragmentation Unused memory remains inside an allocated area.
External Fragmentation Free memory becomes divided into small separate holes.
Compaction Processes are moved to combine scattered free spaces.
First Fit Select the first suitable free hole.
Best Fit Select the smallest suitable free hole.
Worst Fit Select the largest available hole.
Base and Limit Help keep a process inside its valid memory boundary.

Frequently Asked Questions

What is Fixed Partitioning in Operating System?

Fixed Partitioning is a contiguous memory allocation technique in which main memory is divided into a fixed number of predefined partitions and a process is loaded into one suitable free partition.

What is Variable Partitioning in Operating System?

Variable Partitioning is a memory allocation technique in which partitions are created dynamically according to the memory requirements of processes.

Which fragmentation occurs in Fixed Partitioning?

Fixed Partitioning mainly suffers from internal fragmentation because a process may not use the complete partition assigned to it.

Which fragmentation occurs in Variable Partitioning?

Variable Partitioning mainly suffers from external fragmentation because free memory can become divided into several scattered holes.

What is Internal Fragmentation?

Internal fragmentation is wasted memory that exists inside an allocated memory block or partition.

What is External Fragmentation?

External fragmentation occurs when free memory is available but divided into many small non-contiguous holes.

What is Compaction in Operating System?

Compaction moves processes in memory so that scattered free holes can be combined into one larger continuous free block.

What is First Fit?

First Fit selects the first available memory hole that is large enough to store the process.

What is Best Fit?

Best Fit selects the smallest available memory hole that is still large enough to hold the process.

What is Worst Fit?

Worst Fit selects the largest available memory hole for the process.

What are Base and Limit Registers?

The Base register stores the starting physical address of a process, while the Limit register defines its valid logical address range. Together they can help protect process memory.

Conclusion

Fixed Partitioning and Variable Partitioning are basic memory management techniques that explain how an operating system can divide main memory and place several processes inside it.

In Fixed Partitioning, memory is divided into predefined areas. This method is simple, but a process may not use the complete partition. That unused space creates internal fragmentation.

In Variable Partitioning, partitions are created according to the actual requirements of processes. This improves flexibility, but free memory may eventually become scattered into small holes. This creates external fragmentation.

Allocation strategies such as First Fit, Best Fit and Worst Fit decide which free hole should be selected. Compaction can rearrange processes to create a larger continuous free area.

Finally, memory management is not only about allocation. Processes must also be protected from accessing memory that does not belong to them. Base and Limit registers provide a simple way to understand such memory boundaries.

Final Memory Trick:

Fixed Partitioning = Predefined Partitions + Internal Fragmentation

Variable Partitioning = Dynamic Partitions + External Fragmentation

Compaction = Join Scattered Free Spaces

First Fit = First Suitable Hole

Best Fit = Smallest Suitable Hole

Worst Fit = Largest Hole

Base and Limit = Memory Protection

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Join Telegram Exam updates and free resources