Overhead of pthread_mutex_lock(&m) if m is not locked. Should be very fast and return immediately.
Windows has mutex objects but it also has additional methods that are also functionally equivalent to pthread's mutexex:
- EnterCriticalSection
- LeaveCriticalSection
Windows essentially uses the one-level model, BUT the EnterCriticalSection and LeaveCriticalSection methods are implemented (at least partially) in user level library.
Claim: Using EnterCriticalSection/LeaveCriticalSection is 20 times faster than using Windows mutexes when no waiting is necessary.
Note: If the critical section is locked, EnterCriticalSection must make a system call to block the calling thread.