/    /  OS -Segmentation in Operating System

Segmentation in Operating System

 

What is segmentation?

Segmentation is a memory management technique where the memory is divided into variable size parts known as segments

The segment table stores the details of the segments. It mainly consists of two information:

  1. The base address of the segment.
  2. The length of the segment.

 

There are two types of segmentation:

  1. Virtual memory segmentation: In this, the process is divided into several segments, not all of which reside at one point at a given time.
  2. Simple segmentation: In this, the process is divided into several segments, all of which are loaded into the memory at run time.

 

Translation of Logical address into a physical address by segment table:

 

The logical address generated by the CPU consists of two parts:

  1. Segment Number: It is the number of bits required to represent a segment. 
  2. Offset: It is the number of bits required to represent the size of the segment.

 

The segment number is mapped to the segment table, and then the segment’s limit is compared to the offset. If the offset is lesser than the limit, then the address is valid.

If the address is valid, the base address will be added to the offset.

 

Advantages of segmentation:

The advantages of segmentation are as follows:

  1. There is no internal fragmentation.
  2. There is lesser overhead.
  3. It is easier to relocate segments.
  4. The size of the segment table is smaller than the page table.
  5. The size of the segment is larger than the page size. 

 

Disadvantages of segmentation:

The disadvantages of segmentation are as follows:

  1. There may be external fragmentation.
  2. It is a costly memory management allocation.

 

Reference

Segmentation in Operating System