Mutexes and error checking

Andriy Gapon avg at FreeBSD.org
Sun Jul 21 16:28:05 UTC 2013


on 21/07/2013 19:02 Jilles Tjoelker said the following:
> So I think allowing pthread_mutex_unlock() by a different thread would
> be a step backwards.

There is something else that bothers me too.
Properly written code always "knows" whether it has a lock or not.  It does not
try to unlock on a whim.  Apparently the software in question is not properly
written.  Nevertheless, it takes care to check return status of
pthread_mutex_unlock().  And, to add insult to injury, it depends on OS-specific
behavior in doing so.  That seems like "two wrongs make a right" thing.

I understand that "life is such", etc, but it hurts to see us bend for such a
backwards code.

-- 
Andriy Gapon


More information about the freebsd-threads mailing list