Data structures of a Windows thread

Operating SystemWindowsMCA

Windows implements the Windows API, which is the primary API for the family of Microsoft operating systems (Windows 98, NT, 2000, and XP, as well as Windows 7). Basically A Windows application runs as a separate process, and each process may contain one or more threads. Additionally, Windows uses the one-to-one mapping, where each user-level thread maps to an associated kernel thread. The general components of a thread include −

  • A thread ID uniquely identifying the thread

  • A set of register representing the status of the processor

  • A stack of user, employed when the thread is running in user mode, and a kernel stack, employed when the thread is running in kernel mode

  • A private storage area used by various run-time libraries and dynamic link libraries (DLLs) The register set, stacks, and private storage area are known as the context of the thread.

The primary data structures of a thread include −

  • ETHREAD - executive thread block
  • KTHREAD - kernel thread block
  • TEB - thread environment block

The essential components of the ETHREAD include a pointer to the process to which the thread belongs and the address of the routine in which the thread starts control. The ETHREAD also contains a pointer to the corresponding KTHREAD. The KTHREAD includes scheduling and synchronization information for the thread. In addition, the KTHREAD includes the kernel stack (used when the thread is running in kernel mode) and a pointer to the TEB. The ETHREAD and the KTHREAD exist entirely in kernel space; this means that only the kernel can access them. The TEB is a user-space data structure that is accessed when the thread is running in user mode. Among other fields, the TEB contains the thread identifier, a user-mode stack, and an array for thread-local storage. The structure of a Windows thread is illustrated in below Figure −

Figure: Data Structures of Windows XP Thread

raja
Published on 17-Oct-2019 09:08:56
Advertisements