Segmentation is a memory-management scheme that supports user view of memory. A program is a collection of segments. A segment is a logical unit such as the main program, procedure, function, method, object, local variables, global variables, common block, stack, symbol table, arrays etc.
A logical-address space is a collection of segments. Each segment has a name and a length. The user specifies each address by two quantities: a segment name/number and an offset.
Hence, the Logical address consists of a two-tuple: <segment-number, offset>
Segment table maps two-dimensional physical addresses and each entry in the table has:
base – contains the starting physical address where the segments reside in memory.
limit – specifies the length of the segment.
Segment-table base register (STBR) points to the segment table’s location in memory.
Segment-table length register (STLR) indicates the number of segments used by a program.
The segment number is used as an index into the segment table. The offset d of the logical address must be between 0 and the segment limit. If it is not, we trap to the operating system that logical addressing attempt beyond an end of the segment. If this offset is legal, it is added to the segment base to produce the address in physical memory of the desired byte.
Consider we have five segments numbered from 0 through 4. The segments are stored in physical memory as shown in the figure. The segment table has a separate entry for each segment, giving start address in physical memory (or base) and the length of that segment (or limit). For example, segment 2 is 400 bytes long and begins at location 4300. Thus, a reference to byte 53 of segment 2 is mapped onto location 4300 + 53 = 4353.