Thread kernel objects (thread kernel object)
The OS allocates and initializes one of these data structures for each thread created in the system. In this data structure, contains a set of properties that describe a thread.
The data structure also contains the so-called threading context (thread contexts). A context is a block of memory that contains a collection of registers for the CPU.
When Windows runs on a computer that uses X86 CP, the thread context uses approximately 700 bytes of memory. For X64 and IA64 CPUs, the context separately
Use approximately 1240 bytes and 2500 bytes of memory.
Thread environment block (thread environment BLOCK,TEB)
TEB is a block of memory that is allocated and initialized in user mode (the address space that the application code can quickly access). TEB consumption of 1 memory pages
(The X86 and X64 CPUs are 8KB in the 4kb,ia64 CPU). TEB contains the header of the thread's exception handling chain (head). Each try block entered by the thread is
The top of the chain is inserted into a node. When the thread exits the try block, the node is deleted in the flushing chain. In addition to this, TEB also contains thread-local storage data for threads,
There are some data structures that are used by GDI (graphics device Interface, graphic devices interface) and OpenGL graphics.
User mode stack (user-mode stack)
The user-mode stack is used to store local variables and arguments passed to the method. It also contains an address that indicates where the thread should start executing when the current method returns.
By default, Windows allocates 1MB of memory for each new Metro user-mode stack.
Kernel-mode stack (Kernel-mode stack)
The kernel-mode stack is also used when application code passes arguments to a function in the operating system's kernel mode. For security reasons, code from user mode
Any arguments passed to the kernel, Windows will copy them from the thread's user-mode stack to the thread's kernel-mode stack. Once copied, the kernel validates the value of the argument.
Because the application code cannot access the kernel-mode stack, the application cannot modify the argument values after validation. The OS kernel code will begin processing the copied values. Besides
The kernel invokes its own internal method and uses the kernel-mode stack to pass its own arguments, store the local variables of the function, and store the return address. On 32-bit Windows
At run time, the kernel-mode stack size is 12KB, while running on 64-bit Windows, the size is 24KB.
DLL thread connection (attach) and thread detach (detach) notifications
One of the policies of Windows is that any time a thread is created in the process, it invokes the DllMain method of all DLLs that are loaded in progress, and passes the method a
Dll_thread_attach logo. Similarly, when a thread terminates, the DllMain method of all the DLLs in progress is called, and the method is passed a
Dll_thread_detach logo. A little DLL needs to be picked up with these notifications to perform some special initialization or (resource) cleanup operations for each thread created and destroyed in the process.
For example, the C-runtime library DLL allocates some thread-local storage state. These states are required for threads to use the functions contained in the C-runtime library.
CLR Via C # Learning-thread Overhead