Protected Mode (Flat Memory Model)

The 80386 is able to address up to 4GB in a single segment. This is a large address space. It may, therefore, be desirable not to use the segmented memory model, but simply to map the entire system memory as a single linear address range. While the 80386 does not have a mode bit for disabling segmentation, the same effect can be achieved by mapping the stack, code, and data spaces to the same range of linear addresses. When this is done, the 32-bit offsets used by 80386 memory references can cover the entire linear address space.

OS/2 Version 2.0 uses this technique to implement a flat addressing model. The operating system internally creates a single code segment and a single data segment, with the base address of each segment selector set to zero, and a segment size of 4GB. This segment selector is loaded into the CS, DS, ES, FS, GS, and SS registers; hence these registers all point to the same memory range. The selectors are allocated within the GDT. Offsets within the segment are actually offsets within the 4GB global address space, and are therefore equivalent to linear memory addresses.

The advantage of using such a technique is that it greatly simplifies memory management within an application, since the application developer no longer need be concerned with the internal implementation of data structures as segments with a defined maximum size. The use of a flat memory model also facilitates migration of the operating system and application code to other hardware platforms, since the code is not explicitly designed around the segmented memory model. Application performance is also improved since there is no longer the need for continually changing the contents of segment registers. All address references are near references as with a 32-bit offset, you can access the entire address space.


[Back: Protected Mode (Segmented Memory Model)]
[Next: Paging]