Flat Memory Model Article Index for
Flat
Website Links For
Flat
 

Information About

Flat Memory Model





Advantage over Harvard architecture

The flat memory model offers the advantage of programming simplicity over the other models mentioned above. A memory address is always unambiguous in the flat memory model, referring to a well-defined memory location. In contrast, a memory address the Harvard architecture requires an additional qualifier to distinguish a code address from a data address. This means added bookkeeping complexity for the Programmer .


Advantage over segmented model

A similar complexity issue exists with the segmented memory model, as implemented on the now ubiquitous Intel 80x86 family of microprocessors. The segmented model divides a large memory address space into smaller chunks (called Segment s) that can be accessed by giving each chunk a unique number, called a ''' Selector '''. In order to do this, a special '''segment register''' is used to select the segment you wish to use, then the selected segment is made to look like a normal flat piece of memory. Using this configuration, a 16-bit microprocessor can access up to 4 Gibibyte s of memory (65536 segments of 65536 bytes). However, in Real Mode the arrangement of a Segmented Memory Model is where a 16-bit (64 KiB) addressing space is overlapped every 16 bytes (called a '''paragraph''') in order to create a 1 Mebibyte total addressing space.

In Protected Mode the lower 3 bits of a selector are NOT part of the index. Instead the first 2 bits are the ''Requested Privilege Level'' (RPL) of the selector, and the third bit tells the processor which table to look up. If it is zero, the index is in the GDT and if it is one, it is in the current LDT . The processor first checks the Descriptor Privilege Level (DPL) of the accessed segment against both the Current Privilege Level (CPL) and the selector's RPL and Faults on access violations.

If not, the processor looks it up in whenever table the index it is in for the segment base, and if it is not found, it causes a fault. If it is found, it checks if the current operation done is allowed on the segment. If not it faults. If it is allowed, the processor adds the offset to the segment base to form a 24-bit or 32-bit physical address and performs the operation.

Note that on I386 processors, because the index is 13-bit, even in protected mode using a segmented memory model only 1 GiB of Virtual Memory can be accessed at one time (512 MiB global, 512 MiB local).

The advantage of the flat memory model is that applications running in such a model, unlike applications running in a segmented memory model, do not have to switch segments to access additional code or data. Furthermore, manipulating memory and data can be achieved with far fewer internal registers, as shown in the new generation of RISC microprocessors. This drastically simplifies processor architecture from a manufacturing point of view, compiler construction from a tool developer's point of view, and programming complexity from a programmer's point of view.

These simple benefits of the flat memory model have enabled microprocessors utilising the model to outperform microprocessors utilising segmented memory models where most other environmental factors (e.g. microprocessor Clock Speed and memory speed) are considered equal. Put another way, microprocessors utilising a flat memory model have often been shown to achieve equivalent performance of a processor utilising a segmented memory model despite the fact they are running slower clock speeds and have simpler (and cheaper) architectures.