Jump to content

Local Descriptor Table

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 65.110.29.27 (talk) at 00:48, 21 February 2006 (Fading out). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Local Descriptor Table (LDT) is a memory table used in the x86 architecture in protected mode and containing memory segment descriptors: start in linear memory, size, executability, writability, access privilege, actual presence in memory, etc.

The LDT is the sibling of the Global Descriptor Table and similarly defines up to 8191 memory segments accessible to programs.

Past glory

On x86 processors not having paging features, like the Intel 80286, the LDT is essential to implementing separate address spaces for multiple processes. There will be generally one LDT per user process, describing privately held memory, while shared memory and kernel memory will be described by the GDT. The operating system will switch the current LDT when scheduling a new process, using the LLDT machine instruction. On the contrary, the GDT is generally not switched (although this may happen if virtual machine monitors like VMware are running on the computer).

The lack of symmetry between both tables is underligned by the fact that the current LDT can be automatically switched on certain events, notably if TSS-based multitasking is used, while this is not possible for the GDT. The LDT also cannot store certain privileged types of memory segments (eg. TSSes). Finally, the LDT is actually defined by a descriptor inside the GDT, while the GDT is directly defined by a linear address.

Fading out

Starting with the Intel 80386 microprocessor, separation between processes can be also achieved by giving them separate physical memory pages at the same virtual addresses and so a CR3 (also called the PDTR) field was added to the 386 TSS, allowing auto-switching it as well on a task switch. It is also more efficient to implement virtual memory using page-based swapping rather than full segment swapping. Therefore, modern 32-bit x86 operating systems use the LDT very little if they do not run 16-bit code. Conversely, running 16-bit code in the 32-bit environment (such as the OS/2 subsystem in Windows NT) generally means that the LDT has to be fully filled, with descriptors covering the 512 MB virtual address space. The limited size of the LDT means this 16-bit virtual address space has to be limited to 512 megabytes as well.