Notes: Segmentation | Operating System - Computer Science Engineering (CSE) PDF Download

Non-Contiguous Allocation in Operating System

Paging and Segmentation are the two ways which allow a process’s physical address space to be non-contiguous. It has advantage of reducing memory wastage but it increases the overheads due to address translation. It slows the execution of the memory because time is consumed in address translation.
In non-contiguous allocation, Operating system needs to maintain the table which is called Page Table for each process which contains the base address of the each block which is acquired by the process in memory space. In non-contiguous memory allocation, different parts of a process is allocated different places in Main Memory. Spanning is allowed which is not possible in other techniques like Dynamic or Static Contiguous memory allocation. That’s why paging is needed to ensure effective memory allocation. Paging is done to remove External Fragmentation. 

Working 

Here a process can be spanned across different spaces in main memory in non-consecutive manner. Suppose process P of size 4KB. Consider main memory have two empty slots each of size 2KB. Hence total free space is, 2*2= 4 KB. In contiguous memory allocation, process P cannot be accommodated as spanning is not allowed.
In contiguous allocation, space in memory should be allocated to whole process. If not, then that space remains unallocated. But in Non-Contiguous allocation, process can be divided into different parts and hence filling the space in main memory. In this example, process P can be divided into two parts of equal size – 2KB. Hence one part of process P can be allocated to first 2KB space of main memory and other part of process P can be allocated to second 2KB space of main memory. Below diagram will explain in better way: 

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

But, in what manner we divide a process to allocate them into main memory is very important to understand. Process is divided after analysing the number of empty spaces and their size in main memory. Then only we divide our process. It is very time consuming process. Their number as well as their sizes changing every time due to execution of already present processes in main memory.
In order to avoid this time consuming process, we divide our process in secondary memory in advance before reaching the main memory for its execution. Every process is divided into various parts of equal size called Pages. We also divide our main memory into different parts of equal size called Frames. It is important to understand that:
Size of page in process
= Size of frame in memory
Although their numbers can be different. Below diagram will make you understand in better way: consider empty main memory having size of each frame is 2 KB, and two processes P1 and P2 are 2 KB each. 

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

Resolvent main memory, 

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

In conclusion we can say that, Paging allows memory address space of a process to be non-contiguous. Paging is more flexible as only pages of a process are moved. It allows more processes to reside in main memory than Contiguous memory allocation.

Segmentation in Operating System

A process is divided into Segments. The chunks that a program is divided into which are not necessarily all of the same sizes are called segments. Segmentation gives user’s view of the process which paging does not give. Here the user’s view is mapped to physical memory.

There are types of segmentation:

  1. Virtual memory segmentation:
    Each process is divided into a number of segments, not all of which are resident at any one point in time.
  2. Simple segmentation: 
    Each process is divided into a number of segments, all of which are loaded into memory at run time, though not necessarily contiguously.

There is no simple relationship between logical addresses and physical addresses in segmentation. A table stores the information about all such segments and is called Segment Table.

Segment Table: It maps two-dimensional Logical address into one-dimensional Physical address. It’s each table entry has:

  • Base Address: It contains the starting physical address where the segments reside in memory.
  • Limit: It specifies the length of the segment.

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

Translation of Two dimensional Logical Address to one dimensional Physical Address.

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

Address generated by the CPU is divided into:

  • Segment number (s): Number of bits required to represent the segment.
  • Segment offset (d): Number of bits required to represent the size of the segment.

Advantages of Segmentation:

  • No Internal fragmentation.
  • Segment Table consumes less space in comparison to Page table in paging.

Disadvantage of Segmentation: 

  • As processes are loaded and removed from the memory, the free memory space is broken into little pieces, causing External fragmentation.
The document Notes: Segmentation | 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 Notes: Segmentation - Operating System - Computer Science Engineering (CSE)

1. What is non-contiguous allocation in operating systems?
Non-contiguous allocation in operating systems refers to the allocation of memory or disk space to a process in a non-contiguous or fragmented manner. In this type of allocation, the process's memory or disk space is divided into multiple non-contiguous blocks, which may be scattered throughout the memory or disk. This is in contrast to contiguous allocation, where the process's memory or disk space is allocated in a continuous block.
2. How does non-contiguous allocation work?
In non-contiguous allocation, the operating system maintains a data structure, such as a linked list or a table, to keep track of the allocated and free blocks of memory or disk space. When a process requests memory or disk space, the operating system searches for a sufficient number of free blocks that can accommodate the requested size. These free blocks may not be adjacent to each other, resulting in fragmentation.
3. What are the advantages of non-contiguous allocation?
Non-contiguous allocation offers several advantages. Firstly, it allows for efficient utilization of memory or disk space, as free blocks can be allocated even if they are not contiguous. Secondly, it provides flexibility in allocating and deallocating memory or disk space, as the blocks can be allocated and deallocated independently. Lastly, it allows for dynamic growth of processes, as additional blocks can be allocated as needed.
4. What are the drawbacks of non-contiguous allocation?
Non-contiguous allocation also has some drawbacks. One major drawback is fragmentation, which can lead to inefficient memory or disk space usage. External fragmentation occurs when free blocks are scattered throughout the memory or disk, making it challenging to allocate large contiguous blocks. Internal fragmentation occurs when allocated blocks have unused space, wasting memory or disk space.
5. How can fragmentation be managed in non-contiguous allocation?
Fragmentation can be managed in non-contiguous allocation through two techniques: compaction and paging. Compaction involves rearranging the allocated and free blocks in memory or disk space to reduce fragmentation. This technique requires moving the allocated blocks together and the free blocks together, which can be time-consuming. Paging divides memory or disk space into fixed-size blocks called pages and uses a page table to map logical addresses to physical addresses. This allows for efficient allocation and deallocation of memory or disk space, 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

Objective type Questions

,

practice quizzes

,

MCQs

,

ppt

,

study material

,

Semester Notes

,

Previous Year Questions with Solutions

,

Extra Questions

,

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

,

Summary

,

video lectures

,

Free

,

Viva Questions

,

mock tests for examination

,

Important questions

,

Exam

,

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

,

pdf

,

Notes: Segmentation | Operating System - Computer Science Engineering (CSE)

,

past year papers

,

shortcuts and tricks

,

Sample Paper

;