Segmentation

Filter Course


Segmentation

Published by: Zaya

Published date: 22 Jun 2021

Segmentation Photo

Segmentation

In operating systems, Segmentation is a memory management technique in which, the memory is divided into variable size parts. Each part is known as a segment that can be allocated to a process.

The details about each segment are stored in a table called a segment table. The segment table is stored in one (or many) of the segments.

The segment table contains mainly two information about the segment:

  1. Base: It is the base address of the segment
  2. Limit: It is the length of the segment.

Segmentation

Why Segmentation is required?

Till now, we were using Paging as our main memory management technique. Paging is more close to the Operating system rather than the User. It divides all the process into the form of pages regardless of the fact that a process can have some relative parts of functions which needs to be loaded in the same page.

The operating system doesn't care about the User's view of the process. It may divide the same function into different pages and those pages may or may not be loaded at the same time into the memory. It decreases the efficiency of the system.

It is better to have a segmentation that divides the process into segments. Each segment contain the same type of functions such as the main function can be included in one segment and the library functions can be included in the other segment,

Translation of Logical address into a physical address by segment table

CPU generates a logical address that contains two parts:

  1. Segment Number
  2. Offset

The Segment number is mapped to the segment table. The limit of the respective segment is compared with the offset. If the offset is less than the limit then the address is valid otherwise it throws an error as the address is invalid.

In the case of a valid address, the base address of the segment is added to the offset to get the physical address of the actual word in the main memory.

Segmentation

Advantages of Segmentation

  1. No internal fragmentation
  2. The average Segment Size is larger than the actual page size.
  3. Less overhead
  4. It is easier to relocate segments than the entire address space.
  5. The segment table is of lesser size as compare to the page table in paging.

Disadvantages of Segmentation

  1. It can have external fragmentation.
  2. it is difficult to allocate contiguous memory to variable-sized partition.
  3. Costly memory management algorithms.