[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


2.3.1.3 Errorcheck Mutex

An errorcheck mutex is locked exactly once by a thread, like a normal mutex. If a thread tries to lock the mutex again without first unlocking it, the thread receives an error. Thus, errorcheck mutexes are more informative than normal mutexes because normal mutexes deadlock in such a case, leaving you to determine why the thread no longer executes.

Also, if a thread other than the owner tries to unlock an errorcheck mutex, an error is returned. Errorcheck mutexes are useful during development and debugging. Errorcheck mutexes can be replaced with normal mutexes when the code is put into production use, or left to provide the additional checking. Errorcheck mutexes are always slower than normal mutexes. They cannot be locked without generating a call into DECthreads, and they do more internal tracking.