Jump to content

Memory segmentation

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 74.109.5.17 (talk) at 11:03, 25 July 2011 (→‎Intel segmented memory: clarified: protection on the 80286--real mode and protected mode). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, memory segmentation is one of the most common ways to achieve memory protection; another common one is paging. In a computer system using segmentation, an instruction operand that refers to a memory location includes a value that identifies a segment and an offset within that segment. A segment has a set of permissions, and a length, associated with it. If the currently running process is allowed by the permissions to make the type of reference to memory that it is attempting to make, and the offset within the segment is within the range specified by the length of the segment, the reference is permitted; otherwise, a hardware exception is raised.

Moreover, as well as its set of permissions and length, a segment also has associated with it information indicating where the segment is located in memory. It may also have a flag indicating whether the segment is present in main memory or not; if the segment is not present in main memory, an exception is raised, and the operating system will read the segment into memory from secondary storage. The information indicating where the segment is located in memory might be the address of the first location in the segment, or might be the address of a page table for the segment, if the segmentation is implemented with paging. In the first case, if a reference to a location within a segment is made, the offset within the segment will be added to address of the first location in the segment to give the address in memory of the referred-to item; in the second case, the offset of the segment is translated to a memory address using the page table.

In most systems in which a segment doesn't have a page table associated with it, the address of the first location in the segment is an address in main memory; in those systems, no paging is done. In the Intel 80386 and later, that address can either be an address in main memory, if paging is not enabled, or an address in a paged "linear" address space, if paging is enabled.

A memory management unit (MMU) is responsible for translating a segment and offset within that segment into a memory address, and for performing checks to make sure the translation can be done and that the reference to that segment and offset is permitted.

Intel segmented memory

This usage should not be confused with that of the x86 memory segmentation used by early Intel processors such as the Intel 8086 and Intel 8088 (and also the 80186 ans 80188), as they do not provide any protection. Any program running on these can access any segment with no restrictions, and a segment consists of only a starting location and a fixed (implied) length of 64 KiB. Segmentation in the Intel 80286 and later provides protection; with the introduction of the 80286, Intel retroactively named the sole operating mode of the previous x86 CPU models "real mode" and introduced a new "protected mode" with protection features. For backward compatibility, all x86 CPUs start in "real mode"—with no memory protection, fixed 64 KiB segments, and only 20-bit (1024 MiB) addressing—and must be switched into another mode by software in order to use the full address space and advanced MMU features.

References

  • IA-32 Intel Architecture Software Developer’s Manual Volume 3A: System Programming Guide

http://www.intel.com/products/processor/manuals/index.htm

  • Operating Systems: Internals and Design Principles by William Stallings

Publisher: Prentice Hall ISBN 0131479547 ISBN 9780131479548

See also