ThreadWaitReason 的文档

Documentation for ThreadWaitReason

我正在搜索 ThreadWaitReason 1..31 的文档。特别是我对

感兴趣
ThreadWaitReason = 27 
ThreadWaitReason = 31

我发现是 [1]: https://msdn.microsoft.com/en-us/library/aa394494(v=vs.85).aspx 但它只列出到 1..20.

KWAIT_REASON 枚举在 wdm.h 中声明 - 您可以从中查看不同的值(27 是 WrResource,31 是 WrDispatchInt)。

线程对象 (KTHREAD) 本身有 WaitReason 字段。每次,在线程变为等待(不活动)之前,系统都会向该字段写入一些原因值。当我们在内核中直接调用 KeWaitForSingleObject or KeWaitForMultipleObjects we by self set the WaitReason value. when we call another function, which can cause wait - system yourself set WaitReason. for example if call KeDelayExecutionThread (kernel mode implementation of Sleep[Ex] ) system set WaitReason to WrDelayExecution. when we call resource function ( ExAcquireResourceExclusiveLite for example) - system set WaitReason to WrResource (27) . when system swap thread, because it quantum expired - system set WaitReasonWrDispatchInt (31)。等等。

当我们用SystemProcessInformation调用NtQuerySystemInformation时-系统read value from WaitReason and return it in SYSTEM_THREAD_INFORMATION结构。

显然 WaitReason 在线程等待时具有主要意义 - 所以它的状态是 Waiting (5) 。否则我们得到旧值 - 上次线程等待的原因