Eric Grange
Eric Grange

Reputation: 6211

How to check if a thread is waiting?

For purposes of profiling and monitoring, I would like to know if a thread is currently active (using CPU time) or if it is waiting or sleeping.

Is there a way to find out if a thread is currently in one of the various Windows kernel waiting functions?

From WaitForSingleObject to various mutex, sleep, critical section, IOCP GetQueuedCompletionStatus, and other I/O functions etc. there are quite a few functions that can result in a thread waiting.

Is there a standard way to know if a thread is waiting?

Upvotes: 1

Views: 1414

Answers (1)

David Heffernan
David Heffernan

Reputation: 612954

The Wait Chain Traversal API does what you ask. And a whole lot more besides.

Upvotes: 1

Related Questions