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.
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?
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.
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?
Basic Main Memory Layout
The operating system itself occupies some part of RAM. The remaining memory can be used for user processes.
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.
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.
How Fixed Partitioning Works
- Main memory is divided into predefined partitions.
- A process arrives.
- The operating system checks available partitions.
- A suitable partition is selected.
- The process is loaded into that partition.
- When the process finishes, that partition becomes free again.
Types of Fixed Partitioning
Every partition has the same size.
This is simple to manage, but a process larger than one partition cannot be loaded even if total free memory is sufficient.
Different partitions have different sizes.
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.
Suppose the remaining 896 KB is divided into four equal partitions.
Now suppose Process P1 requires only 180 KB.
This 44 KB cannot normally be given to another process because it is inside P1's allocated partition.
Advantages and Limitations of Fixed Partitioning
Fixed partitioning can waste memory because a process may be smaller than the partition assigned to it.
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.
Variable Partitioning is a contiguous memory allocation technique in which partitions are created dynamically according to the memory requirement of processes.
How Variable Partitioning Works
- A process arrives.
- The operating system checks free memory.
- A suitable continuous free area is selected.
- A partition is created according to process requirement.
- The process is loaded.
- 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.
Now four processes arrive:
Their total requirement is:
Remaining memory:
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:
Unused space exists inside an allocated partition.
This commonly appears in fixed partitioning.
Free memory exists, but it is divided into many small holes.
Total free memory is 50 KB, but it is not one continuous block.
A process requiring 40 KB continuously may fail.
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
Internal fragmentation:
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.
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.
Compaction does not create extra RAM. It only rearranges processes so that existing free memory becomes continuous.
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.
| 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:
Process size:
First Fit
Start checking from the beginning.
Therefore:
Best Fit
Suitable holes:
Smallest suitable hole is 300 KB.
Worst Fit
Largest hole is 600 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 Protection in Partitioned Memory
Memory allocation tells the operating system where a process should stay.
Memory protection answers another important question:
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.
Logical Address Check
Example: 650
Offset less than Limit
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.
Base and Limit Register Solved Example
First check whether the offset is valid.
Now calculate the physical address.
Important Boundary Case
Is offset 1000 valid?
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.
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
- Define memory partitioning.
- Explain Fixed Partitioning.
- Explain Variable Partitioning.
- Explain internal and external fragmentation.
- Write important differences.
For a 10-Mark Question
- Meaning of contiguous memory allocation.
- Need for partitioning.
- Fixed Partitioning.
- Equal and unequal fixed partitions.
- Fixed partition memory diagram.
- Internal fragmentation.
- Variable Partitioning.
- Variable partition memory diagram.
- External fragmentation.
- Compaction.
- First Fit.
- Best Fit.
- Worst Fit.
- Memory protection.
- Base and Limit registers.
- Difference between Fixed and Variable Partitioning.
One-Minute Revision
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.
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
