Concept Of Segmentation in Operating System

In segmentation, programs are divided into variable size segments, instead of fixed size pages. Every logical address is formed of a segment name and an offset within that segment. In practice, segments are numbered. Programs are segmented automatically by the compiler or assembler.

For example, a C compiler will create separate segments for:
1. the code of each function
2. the local variables for each function
3. the global variables.


For logical to physical address mapping, a segment table is used. When a logical address <s, d> is generated by the processor:
1. Base and limit values corresponding to segment s are determined using the segment table
2. The OS checks whether d is in the limit. (0 ≤ d < limit)
3. If so, then the physical address is calculated as (base + d), and the memory is accessed.


Sharing Segments
Also sharing of segments is applicable as in paging. Shared segments should be read only and should be assigned the same segment number.

Example :
Consider a system in which 3 users executing an editor program which is 1500 KB in size, each having their own data space.


3. Paged segmentation

The idea is to page the segments and eliminate the external fragmentation problem. In paged segmentation the logical address is made of <s,p,d> triplet. The ST entry for segment S now, contains:

  •  the length of segment S
  •  the base address of the PT for segment S.

There is a separate PT for every segment. On the average, now there is half a page of internal fragmentation per segment. However, more table space is needed. In the worst case, again three memory accesses are needed for each memory reference. The flowchart for accessing a word with logical address <s,p,d> is shown below.


Share with : Share on Linkedin Share on Twitter Share on WhatsApp Share on Facebook