1 / 28

Thread Internals

Thread Internals. 組員:王傳陞、林威丞 黃品舜、李盈賢. outline. what is a thread? Data Structures executive thread block kernel thread block thread environment block Thread-Related Kernel Variables Thread-Related Performance Counters Windows Thread Functions Birth of a Thread. What is a Thread?.

drea
Télécharger la présentation

Thread Internals

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Thread Internals 組員:王傳陞、林威丞 黃品舜、李盈賢

  2. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  3. What is a Thread? • A thread is the basic object that executes instructions on a processor. All running processes have at least one thread.

  4. What is a Thread?(cont.) • Traditional UNIX Process • Heavyweight process • Single thread • Mach Task • Thread • Lightweight process • Thread id, PC, register set, a stack • Dynamic Object • Mult-thread

  5. What is a Thread?(cont.) Single-threaded process Multi-threaded process Resources Resources Threads Threads

  6. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  7. Data Structures EP : executive process KP : kernel process (PCB) PEB : process environment block ET : executive thread KT : kernel thread TEB : thread environment block

  8. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  9. executive thread block Thread time : Thread create and exit time information. Process identification : Process ID and pointer to EPROCESS block of the process that the thread belongs to. Start address : Address of thread start routine.

  10. executive thread block(cont.) Impersonation information : Access token and impersonation level (if the thread is impersonating a client). LPC information : Message ID that the thread is waiting for and address of message. I/O information : List of pending I/O request packets (IRPs).

  11. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  12. kernel thread block Dispatcher header : A data structure that contains the object type, the signaled state, and a list of the threads waiting on that object. Execution time : Total user and kernel CPU time. Pointer to kernel stack information : Base and upper address of the kernel stack.

  13. kernel thread block(cont.) Pointer to system service table : Each thread starts out with this field service table pointing to the main system service table (KeServiceDescriptorTable). When a thread first calls a Windows GUI service, its system service table is changed to one that includes the GDI and USER services in Win32k.sys.

  14. kernel thread block(cont.) Scheduling information : Base and current priority, quantum, affinity mask, ideal processor, scheduling state, freeze count, and suspend count. Trap frame : Trap frame allow system to resume where if left off. APC queues : List of pending user-mode and kernelmode APCs, and alertable flag.

  15. kernel thread block(cont.) Wait blocks : Each thread that is in a wait state has a list of the wait blocks that represent the objects the thread is waiting for. Timer block : Built-in timer block (also a corresponding wait block). Pointer to TEB : Thread ID, TLS information, PEB pointer, and GDI and OpenGL information.

  16. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  17. thread environment block TIB : One element in the TIB structure is a pointer to an EXCEPTION_RECORD structure, which in turn contains a pointer to an exception handling callback function. Thus, each thread has its own exception callback function. Fiber : lightweight” threads Others : Graphics Device Interface 、 Open Graphics Library、Transport Layer Security…

  18. outline • What is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  19. Thread-Related Kernel Variables Example : 線程監控

  20. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  21. Thread-Related Performance Counters

  22. Thread-Related Performance Counters(cont.) Thread Object詳細資料連結

  23. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

  24. Windows Thread Functions

  25. Windows Thread Functions(cont.)

  26. outline • what is a thread? • Data Structures • executive thread block • kernel thread block • thread environment block • Thread-Related Kernel Variables • Thread-Related Performance Counters • Windows Thread Functions • Birth of a Thread

More Related