HOME

TheInfoList



OR:

The Global Descriptor Table (GDT) is a core part of
Intel Intel Corporation is an American multinational corporation and technology company headquartered in Santa Clara, California, and Delaware General Corporation Law, incorporated in Delaware. Intel designs, manufactures, and sells computer compo ...
's
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel, based on the 8086 microprocessor and its 8-bit-external-bus variant, the 8088. Th ...
architecture that helps manage how memory is accessed and protected. Introduced with the Intel 80286 processor, it plays a key role in defining memory segments and their attributes: the base address, the size, and access privileges like executability and writability. Even though modern 64-bit systems rarely rely on segmentation, the GDT remains a required component for starting up the processor and managing certain system-level tasks.


Description

The GDT helps isolate memory between
application software Application software is any computer program that is intended for end-user use not operating, administering or programming the computer. An application (app, application program, software application) is any program that can be categorized as ...
and the
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
. In
protected mode In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units (CPUs). It allows system software to use features such as Memory_segmentation, segmentation, virtual mem ...
(a more advanced processor mode that allows memory protection), the GDT defines: * Code segments: regions of memory that contain executable instructions. * Data segments: areas used to store program data. * System segments, like the Task State Segment (TSS), which is used for multitasking support. Each entry in the GDT is 8 or 16 bytes long and holds a segment descriptor that defines the properties of one segment. Each descriptor includes access rights, ensuring programs cannot modify protected memory. To use a segment, a program refers to it using a segment selector — a special value that tells the processor which GDT entry to use. The processor then loads this descriptor into a segment register, which holds both visible and hidden metadata about the segment.


GDT in 64-bit

In 64-bit mode, segmentation is mostly disabled: all segment bases are treated as zero, and limits are ignored, creating a flat address space. However, the GDT is still required to define system descriptors such as the Task State Segment (TSS). Two segment registers, FS and GS, remain active and are often used by operating systems for thread-local storage or process-specific data (e.g., the Thread Environment Block in
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
or gs_base in
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
). Notably, Windows enforces strict protections: attempts to
hook A hook is a tool consisting of a length of material, typically metal, that contains a portion that is curved/bent back or has a deeply grooved indentation, which serves to grab, latch or in any way attach itself onto another object. The hook's d ...
or modify the GDT in 64-bit versions will trigger a system crash ( bug check).


Local Descriptor Table

While the GDT defines system-wide segments, the Local Descriptor Table (LDT) can define segments that are private to a single process. Historically, operating systems used the LDT to separate each program’s memory into private regions, especially before paging was introduced with the Intel 80386. Today, LDTs are mostly obsolete but may still appear for compatibility with 16-bit or older 32-bit applications (e.g., DOS or
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
programs). The LDT is defined by an entry in the GDT and can include up to 8192 segment descriptors.


History and modern usage

In early x86 systems (like the 80286), segmentation via the GDT and LDT was critical to implementing multitasking and memory isolation. Each process had its own LDT, while the GDT held global definitions. The system could automatically switch the current LDT when changing tasks, making segment-based isolation efficient. However, with the introduction of
paging In computer operating systems, memory paging is a memory management scheme that allows the physical Computer memory, memory used by a program to be non-contiguous. This also helps avoid the problem of memory fragmentation and requiring compact ...
on the 80386, operating systems began using page-based virtual memory instead of segment-based memory. Paging allows fine-grained memory management in 4KB chunks and makes it easier to share or protect memory. As a result, modern operating systems like
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
, and
macOS macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
use a flat memory model, where all code and data segments span the entire
address space In computing, an address space defines a range of discrete addresses, each of which may correspond to a network host, peripheral device, disk sector, a memory cell or other logical or physical entity. For software programs to save and retrieve ...
. The GDT is still involved in system initialization, interrupt handling, and defining special structures like the TSS and LDT pointer. Legacy or compatibility modes (e.g., running 16-bit DOS or OS/2 code) may still use segmentation more actively. In such cases, a technique known as LDT tiling can be used, where the LDT is filled with descriptors that map fixed-size memory blocks (e.g., 64 KB each) to provide coverage for legacy applications.


References


External links


Intel Architecture Software Developer's Manual

GDT Table
at OSDev.org
GDT Tutorial
at OSDev.org



{{Webarchive, url=https://web.archive.org/web/20180423112351/http://brokenthorn.com/Resources/OSDev8.html , date=2018-04-23 X86 architecture Memory management