Basics of Windows Mutexes and Spin Locks

Windows mutex is a synchronization object.  Mutexes ensure mutually exclusive (hence the term) access.  In other words, while one thread has the mutex, all other threads are prevented from using it.  Essentially any lock that grants mutually exclusive access is a mutex. There’re different types of mutexes – and determining which one will be used is based […]

Windows mutex is a synchronization object.  Mutexes ensure mutually exclusive (hence the term) access.  In other words, while one thread has the mutex, all other threads are prevented from using it.  Essentially any lock that grants mutually exclusive access is a mutex. There’re different types of mutexes – and determining which one will be used is based on a number of factors, including: At what IRQL can the mutex be acquired and released? Does acquiring the mutex raise the current IRQL? Must the mutex be released on the same thread that acquired it? Can the mutex be acquired by a thread more than once without releasing it (i.e. recursively)? What happens to a mutex if the thread that is holding it is terminated?.

More infoPerformance Blog