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 assembler or compiler generates object code in which each line of object code is associated with a particular segment based on programmer's original source code. The programmer most specify to which segment a particular instruction or data value belongs. It is the assembler/compiler that generates object code that reflects these assignments. The loader will make the segment number assignments.


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.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Follow by Email

Blog Archive

Powered by Blogger.

- Copyright © 2013 Taqi Shah Blogspot -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -