Segmentation

Download PDF
Advertisement

Segmentation

An essential feature of memory management that became mandatory with paging is the separation of the view of memory by the user and the actual physical memory. The view of memory for user is not the same as the actual physical memory. The user’s view is recorded onto physical memory. This mapping allows distinction between physical memory and logical memory. Segmentation is a procedure to break memory into logical pieces where each and every piece represents group of associated information. For example, code segment or data segments for every process, data segment for operating system and so on.

Segmentation can be implemented with help of using or without using paging. Distinct paging, segment is having altering sizes and thus excludes internal fragmentation. External fragmentation still exists but to minor degree.

Segmentation

Segmentation is a memory-management structure that supports this user view of memory. A logical address-space is a pool of segments. For each segment it has a name and a length. The addresses identify both the segment name and the offset inside the segment. The user then specifies each address by two quantities: an offset and a segment name. Compare this scheme with the paging scheme and in which the user specifies only a single address, that is partitioned by the hardware into an offset and a page number all remains invisible to the programmer. For ease of implementation segments are numbered and are stated by a segment number, rather than by a segment name. So, a logical address contains two tuples:

Advertisement


<segment-number, offset>

Generally, when the user program is compiled, and the compiler automatically creates segments reflecting the input program. A C compiler might create the following separate segments:

  • The code
  • Global variables
  • The heap, from which memory is allocated
  • The stacks which are used by each thread
  • The standard C library

Libraries might be assigned separate segments that ate linked during compile time. Loader would have assigned number to all these segments.

Address produced by CPU is divided into:

Segment number (s) — segment number S is used to represent an index into a segment table
which holds base address of each segment in a limit of segment and physical memory.

Segment offset (o) — segment offset O is first checked against limit and then is joined
with base address to delineate the physical memory address.

Segmentation

 

Paging in operating system

Advertisement

Leave a Reply

Please rate us