Protected Mode (Segmented Memory Model)

When the 80386 is switched to protected mode by a software command, the full 32-bit capabilities of the processor are enabled, and the system's physical address space is increased to 4GB. Since virtual memory support is enabled in protected mode, the virtual address space visible to an application increases to a theoretical maximum of 64 terabytes.

Note: In OS/2 Version 2.0, the process address space is limited to 512MB in order to reserve memory for operating system use and to retain full compatibility with applications written for previous versions of OS/2, which used 16-bit addressing.

Each process occupies a separate logical address space, and the 80386 provides full memory protection between the address spaces of different processes, thereby preventing an application from inadvertently accessing and/or corrupting memory used by another application. Note, however, that under OS/2 Version 2.0, multiple threads may be created within a single process, and dispatched independently by the operating system. These threads share a common address space, and it is therefore the responsibility of the application developer to ensure correct behavior of and synchronization between multiple threads within a single process.

In protected mode, the 16-bit segment registers are used in conjunction with a 32-bit offset to give a 48-bit selector:offset pointer. The segment registers no longer contain the segment base address; rather, they contain an index into a descriptor table. The entries in the descriptor table each point to the start of a segment in physical memory.

Of the 16 bits which make up the segment selector, two bits are used to specify the privilege level of the segment, and one bit is used to select between the global descriptor table (GDT) and a local descriptor table (LDT). The GDT is used by the operating system or privileged software to maintain control over all segments within the system. A unique LDT is maintained for each process and used to control only the memory segments used by that process. In this way, each process is prevented from accessing the memory used by another process. The remaining 13 bits are used as the index into the appropriate descriptor table. A logical address which consists of a selector and offset is converted into a 32-bit linear address by extracting the segment base address from the descriptor table by using the selector as the index, then adding the offset to the base address. With paging disabled, the linear address equates the physical memory address. This address translation operation is shown in Figure "Protected Mode Addressing - without Paging". The virtual address space, which can consist of up to 16,383 segments of 4GB each, is thus mapped to the physical 4GB address space. The descriptor also contains access information for the segment along with the segment size. The access information and segment size is used by the processor to implement memory protection.

The maximum allowable value for the offset, and thus the maximum size of a segment, is defined by two things. Each entry in a descriptor table contains a 20-bit limit field. These 20 bits allow a maximum segment size of 1MB, using the byte as the unit of size.

However, the descriptor table entry also contains a granularity bit, which specifies that either the byte or the page may be used as the unit of size in the limit field. When using page granularity, the 20 bits in the limit field represent a multiple of 4KB, allowing a segment size of 4KB to 4GB.


[Back: Real Mode]
[Next: Protected Mode (Flat Memory Model)]