Wednesday, October 23, 2013

Mutexes Vs. Semaphores

"A mutex is really a semaphore with value 1"
No, no and no again. Unfortunately this kind of talk leads to all sorts of confusion and misunderstanding
While mutexes indeed are similar to binary semaphores, there is one significant difference: the principle of ownership. And fortunately Niall picked up that up in his excellent series on Mutexes vs. Semaphores. Here is part 1, part 2 and part 3.

Another one, more compact explanation comes from Michael Barr in Mutexes and Semaphores Demystified.