×

Operating System Tutorial

Operating System Practice

Segmentation in Operating System

In this tutorial, we will learn about the operating system segmentation, its advantages, and disadvantages, basic methods of segmentation and Hardware support for segmentation. By Monika Jha Last updated : May 05, 2023

Why Segmentation is required?

In the Operating System, an important drawback of memory management is the separation of the user's view of memory and the actual physical memory. Paging is the scheme which provides the separation of these two memories.

The user's view is mapped onto the physical storage. This mapping permits differentiation between logical memory and physical memory.

Operating System may divide the same function into different pages and those pages may or may not be loaded at the same time into the memory and it doesn't care about the User's view of the process. This technique decreases the efficiency of the system.

Segmentation is better than this because it divides the process into the segments.

What is Segmentation in OS?

Segmentation is a memory management technique which supports user's view of memory. This technique of division of a computer's primary memory into sections called segments.

Types of Segmentation

The following are the types of segmentation:

1. Virtual memory segmentation

Each processor job is divided into several segments, It is not essential all of which are resident at any one point in time.

2. Simple segmentation

Each process is divided into many segments, and all segments are loaded into the memory at run time, but not necessarily contiguously.

Basic Method for Segmentation

In a computer system using segmentation, a logical address space can be viewed as multiple segments. The size of the segment may grow or shrink that is it is of variable length.

During execution, each segment has a name and a length. The address specifies both the segment name and the displacement within the segment. The user, therefore, specifies each address by two quantities; segment name and an offset.

Normally it is implemented as segments are numbered and are referred to by a segment number, in place of a segment name. Thus a logical address consists of two tuples:

< segment – number, offset >

Segment number(s) – It is the total number of bits required to represent the segment.

Segment Offset(d) – It specifies the number of bits required to represent the size of the segment.

Hardware Support for Segmentation

In the program, the user refers to objects by a two-dimensional address, the actual physical memory is still, of course, a one- dimensional sequence of bytes. Thus we have to define an implementation to map two-dimensional user-defined addresses into one-dimensional physical addresses.

This mapping is affected by a segment table. In the segment table, each entry has a segment base and a segment limit.

Segment Base – It contains the starting physical address where the segment kept in memory.

Segment Limit – It specifies the length of the segment.

The use of the segment table illustrated in this figure:

Segmentation Hardware

Segmentation Hardware

  • The logical address consists of two parts: a segment number (s) and an offset (d) into that segment.
  • The segment number used as an index into the segment table.
  • The offset d of the logical address must be between 0 and the segment limit.
  • If offset is beyond the end of the segment, we trap the Operating System.
  • If offset is in the limit, then it is combined with the segment base to produce the address in physical memory, hence the segment table is an array of base limit and register pairs.

Advantages of Segmentation

The following are the advantages of segmentation:

  • There is no internal fragmentation.
  • Segment Table is used to record the segments and it consumes less space in comparison to the Page table in paging.

Disadvantage of Segmentation

The following are the disadvantage of segmentation:

  • At the time of swapping, processes are loaded and removed from the main memory, then the free memory space is broken into small pieces, cause of this occurs External fragmentation.



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.