Partition Allocation Methods | Operating System - Computer Science Engineering (CSE) PDF Download

Partition Allocation Methods in Memory Management

In the operating system, the following are four common memory management techniques. 

  • Single contiguous allocation: Simplest allocation method used by MS-DOS. All memory (except some reserved for OS) is available to a process. 
  • Partitioned allocation: Memory is divided into different blocks or partitions. Each process is allocated according to the requirement.
  • Paged memory management: Memory is divided into fixed-sized units called page frames, used in a virtual memory environment. 
  • Segmented memory management: Memory is divided into different segments (a segment is a logical grouping of the process’ data or code).In this management, allocated memory doesn’t have to be contiguous. 

Most of the operating systems (for example Windows and Linux) use Segmentation with Paging. A process is divided into segments and individual segments have pages.
In Partition Allocation, when there is more than one partition freely available to accommodate a process’s request, a partition must be selected. To choose a particular partition, a partition allocation method is needed. A partition allocation method is considered better if it avoids internal fragmentation.
When it is time to load a process into the main memory and if there is more than one free block of memory of sufficient size then the OS decides which free block to allocate.

There are different Placement Algorithm:

  • First Fit
  • Best Fit
  • Worst Fit
  • Next Fit
  1. First Fit: In the first fit, the partition is allocated which is the first sufficient block from the top of Main Memory. It scans memory from the beginning and chooses the first available block that is large enough. Thus it allocates the first hole that is large enough.

    Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)
  2. Best Fit Allocate the process to the partition which is the first smallest sufficient partition among the free available partition. It searches the entire list of holes to find the smallest hole whose size is greater than or equal to the size of the process.

    Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)
  3. Worst Fit Allocate the process to the partition which is the largest sufficient among the freely available partitions available in the main memory. It is opposite to the best-fit algorithm. It searches the entire list of holes to find the largest hole and allocate it to process.

    Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)
  4. Next Fit: Next fit is similar to the first fit but it will search for the first sufficient partition from the last allocation point. 

Is Best-Fit really best? 

Although best fit minimizes the wastage space, it consumes a lot of processor time for searching the block which is close to the required size. Also, Best-fit may perform poorer than other algorithms in some cases. For example, see the below exercise. 

Exercise: Consider the requests from processes in given order 300K, 25K, 125K, and 50K. Let there be two blocks of memory available of size 150K followed by a block size 350K. 

Which of the following partition allocation schemes can satisfy the above requests? 

(a) Best fit but not first fit. 

(b) First fit but not best fit. 

(c) Both First fit & Best fit. 

(d) neither first fit nor best fit.
Ans: (b)

Solution: Let us try all options. 

Best Fit: 

  • 300K is allocated from a block of size 350K. 50 is left in the block. 
  • 25K is allocated from the remaining 50K block. 25K is left in the block. 
  • 125K is allocated from 150 K block. 25K is left in this block also. 
  • 50K can’t be allocated even if there is 25K + 25K space available. 

First Fit: 

  • 300K request is allocated from 350K block, 50K is left out. 
  • 25K is be allocated from the 150K block, 125K is left out. 
  • Then 125K and 50K are allocated to the remaining left out partitions. 
  • So, the first fit can handle requests. 

So option (b) is the correct choice.

Partitioning in Operating System

In operating systems, Memory Management is the function responsible for allocating and managing computer’s main memory. Memory Management function keeps track of the status of each memory location, either allocated or free to ensure effective and efficient use of Primary Memory.
There are two Memory Management Techniques: Contiguous, and Non-Contiguous. In Contiguous Technique, executing process must be loaded entirely in main-memory. 

Contiguous Technique can be divided into:

  • Fixed (or static) partitioning
  • Variable (or dynamic) partitioning

1. Fixed Partitioning: This is the oldest and simplest technique used to put more than one processes in the main memory. In this partitioning, number of partitions (non-overlapping) in RAM are fixed but size of each partition may or may not be same. As it is contiguous allocation, hence no spanning is allowed. Here partition are made before execution or during system configure.


Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)

As illustrated in above figure, first process is only consuming 1MB out of 4MB in the main memory.
Hence, Internal Fragmentation in first block is (4 - 1) = 3MB.
Sum of Internal Fragmentation in every block = (4 - 1) + (8 - 7) + (8 - 7) + (16 - 14) = 3 + 1 + 1 + 2 = 7MB.
Suppose process P5 of size 7MB comes. But this process cannot be accommodated inspite of available free space because of contiguous allocation (as spanning is not allowed). Hence, 7MB becomes part of External Fragmentation.

There are some advantages and disadvantages of fixed partitioning.
Advantages of Fixed Partitioning: 

  • Easy to implement:
    Algorithms needed to implement Fixed Partitioning are easy to implement. It simply requires putting a process into certain partition without focussing on the emergence of Internal and External Fragmentation.
  • Little OS overhead:
    Processing of Fixed Partitioning require lesser excess and indirect computational power.

Disadvantages of Fixed Partitioning

  • Internal Fragmentation:
    Main memory use is inefficient. Any program, no matter how small, occupies an entire partition. This can cause internal fragmentation.
  • External Fragmentation:
    The total unused space (as stated above) of various partitions cannot be used to load the processes even though there is space available but not in the contiguous form (as spanning is not allowed).
  • Limit process size:
    Process of size greater than size of partition in Main Memory cannot be accommodated. Partition size cannot be varied according to the size of incoming process’s size. Hence, process size of 32MB in above stated example is invalid.
  • Limitation on Degree of Multiprogramming:
    Partition in Main Memory are made before execution or during system configure. Main Memory is divided into fixed number of partition. Suppose if there are n1 partitions in RAM and n2 are the number of processes, then n2 <= n1 condition must be fulfilled. Number of processes greater than number of partitions in RAM is invalid in Fixed Partitioning.

2. Variable Partitioning

It is a part of Contiguous allocation technique. It is used to alleviate the problem faced by Fixed Partitioning. In contrast with fixed partitioning, partitions are not made before the execution or during system configure. Various features associated with variable Partitioning-

  • Initially RAM is empty and partitions are made during the run-time according to process’s need instead of partitioning during system configure.
  • The size of partition will be equal to incoming process.
  • The partition size varies according to the need of the process so that the internal fragmentation can be avoided to ensure efficient utilisation of RAM.
  • Number of partitions in RAM is not fixed and depends on the number of incoming process and Main Memory’s size.
    Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)

There are some advantages and disadvantages of variable partitioning over fixed partitioning as given below.

Advantages of Variable Partitioning

  • No Internal Fragmentation:
    In variable Partitioning, space in main memory is allocated strictly according to the need of process, hence there is no case of internal fragmentation. There will be no unused space left in the partition.
  • No restriction on Degree of Multiprogramming:
    More number of processes can be accommodated due to absence of internal fragmentation. A process can be loaded until the memory is empty.
  • No Limitation on the size of the process:
    In Fixed partitioning, the process with the size greater than the size of the largest partition could not be loaded and process can not be divided as it is invalid in contiguous allocation technique. Here, In variable partitioning, the process size can’t be restricted since the partition size is decided according to the process size.

Disadvantages of Variable Partitioning

  • Difficult Implementation:
    Implementing variable Partitioning is difficult as compared to Fixed Partitioning as it involves allocation of memory during run-time rather than during system configure.
  • External Fragmentation:
    There will be external fragmentation inspite of absence of internal fragmentation.
    For example, suppose in above example- process P1(2MB) and process P3(1MB) completed their execution. Hence two spaces are left i.e. 2MB and 1MB. Let’s suppose process P5 of size 3MB comes. The empty space in memory cannot be allocated as no spanning is allowed in contiguous allocation. The rule says that process must be contiguously present in main memory to get executed. Hence it results in External Fragmentation.
    Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)

Now P5 of size 3 MB cannot be accommodated in spite of required available space because in contiguous no spanning is allowed.

The document Partition Allocation Methods | Operating System - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Operating System.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
10 videos|99 docs|33 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Partition Allocation Methods - Operating System - Computer Science Engineering (CSE)

1. What are partition allocation methods in memory management?
Ans. Partition allocation methods refer to the techniques used to assign memory partitions to processes in a computer's memory management system. These methods determine how memory is divided and allocated to different processes, ensuring efficient utilization of available memory resources.
2. What are the types of partition allocation methods?
Ans. There are several types of partition allocation methods: 1. Fixed Partitioning: In fixed partitioning, memory is divided into fixed-size partitions, and each partition can accommodate only one process. This method is simple but may lead to internal fragmentation. 2. Variable Partitioning: Variable partitioning allows memory partitions of varying sizes to be allocated to processes dynamically. It can efficiently utilize memory but may lead to external fragmentation. 3. Dynamic Partitioning: Dynamic partitioning allocates memory partitions based on the size of the process. It allows for efficient memory utilization and eliminates fragmentation issues to some extent. 4. Buddy System: The buddy system allocates memory in powers of two sizes and is based on the concept of splitting and merging buddies. It reduces external fragmentation but may result in internal fragmentation. 5. Best Fit, Worst Fit, and First Fit: These are allocation strategies used within variable partitioning. Best fit selects the partition closest in size to the process, worst fit selects the largest available partition, and first fit allocates the first available partition that meets the process's size requirement.
3. What is internal fragmentation in partition allocation methods?
Ans. Internal fragmentation occurs when the allocated memory block or partition is larger than the actual size of the process it is assigned to. As a result, a portion of the allocated memory remains unused, leading to inefficient memory utilization. Internal fragmentation is more common in fixed partitioning, where each partition has a fixed size.
4. How does external fragmentation affect partition allocation methods?
Ans. External fragmentation refers to the situation when free memory blocks are scattered throughout the memory, making it difficult to allocate contiguous memory space to a process, even if the total free memory is sufficient. It can lead to inefficient memory utilization as processes may not be able to find enough contiguous memory space to be allocated, even though there is enough free memory available in total.
5. Which partition allocation method is the most efficient?
Ans. The most efficient partition allocation method depends on various factors such as the memory management system, the characteristics of the processes, and the specific requirements of the system. Different methods have their advantages and disadvantages. However, dynamic partitioning with best fit allocation strategy is often considered efficient as it dynamically allocates memory partitions based on the process size and selects the partition closest in size, minimizing wastage of memory and reducing fragmentation.
10 videos|99 docs|33 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

study material

,

ppt

,

Previous Year Questions with Solutions

,

Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)

,

Objective type Questions

,

mock tests for examination

,

Exam

,

Extra Questions

,

MCQs

,

practice quizzes

,

Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)

,

Free

,

Summary

,

Sample Paper

,

Viva Questions

,

shortcuts and tricks

,

past year papers

,

Semester Notes

,

Important questions

,

pdf

,

Partition Allocation Methods | Operating System - Computer Science Engineering (CSE)

,

video lectures

;