ADVERTISEMENT
ADVERTISEMENT

Home » Operating Systems

Segmentation in Operating System

In this tutorial, we are going to learn about the operating system segmentation, its advantages, and disadvantages. Here article also comprises the basic method of segmentation and Hardware support for segmentation.
Submitted by Monika Jha, on September 23, 2019

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?

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

  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

  • 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

  • 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.
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.