December 12th, 2006

A high waiter count on a free critical section may indicate a lock convoy

If you’re debugging a performance problem in your application, you may run across a critical section in a very strange state: A lot of threads are waiting for it, but nobody owns it!

0:000> !critsec 0x10009C70
CritSec at 0x10009C70
LockCount          37
RecursionCount     0
OwningThread       0

This state means that the previous owner of the critical section has just exited it and signalled a waiting thread to take it, but that thread hasn’t yet gotten a chance to run yet. This is normally a transient condition, but if you see it a lot, then you very likely the victim of a lock convoy.

Others have written about lock convoys, so I’m just going to refer you to them to get the details.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.

Feedback