- Back to Home »
- Segmentation in Operating System
Segmentation in Operating System:
Definition and Explanation:
Segmentation is a process of of breading program into logical segments and allocating space for these segments in memory separately. The segments can be of variable, lengths. They may not be allocated contiguous memory. The segments are more flexible. They are visible to the programmers. The programmer can use them to tell the system to bring certain data into main memory always together. The disadvantage of segmentation is that the programmer must manage segments whether he wants or not. Segmentation suffers from external fragmentation that is more difficult to deal.
The systems utilizing a paged memory management system must handle the mapping of logical memory onto the physical memory. In a paged environment the user's view of memory (the logical view) is much different than system's view of memory. Typically, the user views memory as a collection of different sized segments containing different components of their application with no implied ordering amongst the segments.
Example:
For example, the user will view one segment as containing their main program. He views another segment containing a subroutine. Another segment may contain common library routines. Another segment holds the symbol table for their program. A user does not view the memory as a contiguous sequence of bytes. Items in a segment are addressed by their offset within the segment such as "the third symbol in the symbol table" or "the 15th line of code".
The segmentation views the logical address space as a collection of segments where each segments has a name (typically just an integer number) and a length. Logical addresses are generated by the programmer and transmitted to MMU by CPU. They must specify both the segment name and the offset in the segment.
The paging system partitioned a single logical address into page number and offset components. A logical address in a system using segmentation consists of
The user now has a two-dimensional view of memory. It is based upon their logical addresses consisting of a segment number and an offset. The segmented system must map the two-dimensional logical addresses onto the one-dimensional addresses corresponding to the actual physical memory. It requires additional hardware support.
Segment Table:
A segment table is maintained which contains information about every segment in a user program (process). Each entry in the segment table contains (among other things) a base value and a limit value. This makes the segment table essentially a set of base-limit register pairs. The base value contains the actual physical address in memory where the segment currently resides. The limit value contains the size (or length) of the segment.