Non-Contiguous Allocation in Operating System


Operating systems assign memory to processes using the memory management strategy known as non-contiguous allocation. This method divides memory into fixed-size blocks or partitions, and each partition can be assigned to a process according to its needs in terms of size.

The non-contiguous allocation permits a process's memory to be dispersed among several regions in the main memory, in contrast to the contiguous allocation, where a process occupies a single block of memory. When working with processes of varying sizes, this strategy offers greater flexibility and effective memory utilization.

In this article, we will be exploring what is Non-Contiguous Memory Allocation, its techniques, use cases, benefits, and drawbacks.

What is a Non-Contiguous Memory Allocation?

It lets a process acquire several memory blocks in various locations in memory, depending on its requirements. Because it makes use of the memory gaps created by internal and external fragmentation, non-contiguous memory allocation also lowers memory waste brought on by internal and external fragmentation.

Paging and segmentation are the two techniques for preventing a process's physical address space from being contiguous. Non-contiguous memory allocation divides the process into blocks (or pages or segments), which are subsequently allotted to different memory locations in accordance with the quantity of free memory.

Non-contiguous memory allocation can save unused memory, but it also raises the price of address translation. Because address translation requires time when the process elements are stored in separate locations in memory, the memory execution is delayed.

With this type of memory allocation, a process can acquire several memory blocks at different locations as needed. The available free space is distributed throughout, as opposed to contiguous memory allocation, where all the available space is allocated in one location.

Allocating non-contiguous memory moves more slowly than allocating contiguous memory. Included are segmentation and paging. There is no memory loss as a result of this allocation.

Techniques Used for Non-Contiguous Allocation

The following techniques are used for non-contiguous allocation.

Linked List − Each process is given memory blocks that are connected by pointers in the linked list approach. The pointers enable traversal from one block to another when the process is given many blocks. Although this method necessitates additional space for the pointers, it enables effective memory allocation and deallocation.

Paging − Paging creates fixed-size pieces of memory called pages by partitioning both the logical and physical memory. While the logical memory is divided into identically sized pages, the physical memory is divided into frames. A page table that links logical pages to physical frames is kept up to date by the operating system. Physical memory frames can be split up to accommodate the non-contiguous allocation of each process's pages.

Segmentation − Segmentation divides the logical memory into segments of varying sizes. Each segment, such as a code segment, data segment, or stack segment, represents a logical unit of a process. A segment table is kept to map logical segments to physical memory locations despite the fact that the segments are dispersed throughout physical memory. Although this approach offers flexibility, it might cause external fragmentation.

Non-Contiguous Allocation Use Cases in Operating System

Here are some use cases for non-contiguous allocation in operating systems.

Variable-sized processes − Non-contiguous allocation is particularly useful when dealing with processes of varying sizes. It allows memory to be dispersed among several regions, enabling efficient utilization of available memory.

Dynamic memory management − Non-contiguous allocation enables dynamic memory management, allowing memory to be allocated and deallocated in response to the initiation or termination of activities. This flexibility is essential in environments where processes have changing memory requirements.

Effective memory utilization − Non-contiguous allocation ensures efficient memory utilization by allocating memory blocks according to the actual needs of the processes. It prevents wasting memory by allocating only the necessary amount of memory for each process.

Fragmentation management − While non-contiguous allocation can increase external fragmentation, it helps reduce internal fragmentation. Internal fragmentation occurs when allocated memory blocks have empty or partially utilized space. By allocating memory blocks based on the specific needs of processes, internal fragmentation is minimized.

Handling large datasets − Non-contiguous allocation is beneficial when dealing with large datasets that cannot fit into a single contiguous memory block. The ability to allocate memory in multiple non-contiguous blocks allows processes to work with extensive data without exhausting the available memory resources.

Virtual memory systems − Non-contiguous allocation is a fundamental technique used in virtual memory systems. It allows the operating system to map logical addresses to physical addresses in a flexible manner, enabling processes to access memory in a non-contiguous fashion.

Multi-programming environments − In multi-programming environments where multiple processes are running concurrently, non-contiguous allocation helps allocate memory blocks to different processes efficiently. Each process can be assigned memory based on its specific requirements, allowing for optimal memory usage.

Real-time systems− Non-contiguous allocation can be useful in real-time systems where processes have stringent timing requirements. It allows memory to be allocated and deallocated dynamically, enabling processes to efficiently manage their memory resources while meeting strict timing constraints.

Benefits of Non-Contiguous Memory Allocation

Efficient Memory Utilization − Non-contiguous allocation makes it possible to use memory effectively by allocating memory blocks according to the real needs of the processes.

Flexibility− Flexibility in memory management is made possible by non-contiguous allocation. It enables processes to receive memory in a fragmented fashion, enabling them to fit into memory blocks that are accessible in a range of sizes.

Dynamic Memory Management − Non-contiguous allocation enables dynamic memory management, allowing memory to be allocated and deallocated in response to the initiation or termination of activities.

Simplified External Fragmentation − External fragmentation is made easier to understand by the fact that non-contiguous allocation lessens its prevalence when compared to contiguous allocation.

Drawbacks of Non-Contiguous Memory Allocation with real-time examples

Fragmentation − Non-contiguous allocation can reduce internal fragmentation while increasing outward fragmentation. Internal fragmentation, which results in ineffective memory utilization, happens when allotted memory blocks have empty or partially utilized space.

Memory Management Overhead − To keep track of allocated memory blocks, their locations, and the process-to-memory mappings, non-contiguous allocation necessitates additional data structures and management techniques.

Memory Externalization − Memory externalization can happen in several non-contiguous memory allocation techniques, such as paging or segmentation.

Conclusion

Operating systems use the memory management strategy of non-contiguous memory allocation to distribute memory to processes. It has a number of benefits, such as effective memory management, adaptability in assigning memory to processes of various sizes, dynamic memory management, and less external fragmentation.

Non-contiguous allocation does, however, have some disadvantages. It may necessitate memory externalization to secondary storage, cause internal fragmentation, raise memory management overhead, and result in longer memory access times.

Updated on: 17-Jul-2023

470 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements