Segmented Addressing - Hardware Implementation

Hardware Implementation

Memory segmentation is one method of implementing memory protection. Paging is another, and they can be combined. The size of a memory segment is generally not fixed and may be as small as a single byte. Segments usually represent natural divisions of a program such as individual routines or data tables so segmentation is generally more visible to the programmer.

A segment has a length and set of permissions associated with it. A process is only allowed to make a reference into a segment if the type of reference is allowed by the permissions, and the offset within the segment is within the range specified by the length of the segment. Otherwise, a hardware exception such as a segmentation fault is raised.

Information is also associated with a segment that indicates where the segment is located in memory. This might be the address of the first location in the segment, or 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.

Segments may also have a flag indicating whether the segment is present in main memory or not; if a segment is accessed that is not present in main memory, an exception is raised, and the operating system will read the segment into memory from secondary storage.

When a segment does not have a page table associated with it, the address of the first location in the segment is usually an address in main memory; in those situations, 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 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.

Read more about this topic:  Segmented Addressing

Famous quotes containing the word hardware:

    A friend of mine spoke of books that are dedicated like this: “To my wife, by whose helpful criticism ...” and so on. He said the dedication should really read: “To my wife. If it had not been for her continual criticism and persistent nagging doubt as to my ability, this book would have appeared in Harper’s instead of The Hardware Age.”
    Brenda Ueland (1891–1985)