tailieunhanh - Windows Internals Covering Windows Server 2008 and Windows Vista phần 6

nhu cầu cao. Bởi vì truy vấn thông tin cần thiết để làm cho quyết định này, cũng như làm việc để tạo ra các chủ đề, đã diễn ra trong chế độ người dùng, một số cuộc gọi hệ thống đã được yêu cầu mà có thể tránh được nếu các hoạt động này được thực hiện trong chế độ hạt nhân. | Chapter 5 Processes Threads and Jobs 387 In Windows Vista the thread pool implementation in user mode was completely re-architected and part of the management functionality has been moved to kernel mode in order to improve efficiency and performance and minimize complexity. The original thread pool implementation required the user-mode code inside to remain aware of how many threads were currently active as worker threads and to enlarge this number in periods of high demand. Because querying the information necessary to make this decision as well as the work to create the threads took place in user mode several system calls were required that could have been avoided if these operations were performed in kernel mode. Moving this code into kernel mode means fewer transitions between user and kernel mode and it allows to manage the thread pool itself and not the system mechanisms behind it. It also provides other benefits such as the ability to remotely create a thread pool in a process other than the calling process although possible in user mode it would be very complex given the necessity of using APIs to access the remote process s address space . The functionality in Windows Vista is introduced by a new object manager type called TpWorkerFactory as well as four new native system calls for managing the factory and its workers NtCreateWorkerFactory NtWorkerFactoryWorkerReady NtReleaseWorker-FactoryWorker NtShutdownWorkerFactory two new query set native calls NtQuery-InformationWorkerFactory and NtSetInformationWorkerFactory and a new wait call NtWaitFor WorkViaWorkerFactory. Just like other native system calls these calls provide user mode with a handle to the TpWorkerFactory object which contains information such as the name and object attributes the desired access mask and a security descriptor. Unlike other system calls wrapped by the Windows API however thread pool management is handled by s native code which means that developers