Boost logo

Boost :

From: Nicolas Fleury (nfleury_at_[hidden])
Date: 2003-06-04 16:08:37

Alexander Terekhov wrote:
> Nicolas Fleury wrote:
>>Thx for the link, but I don't get it. How is Microsoft implementation
>>of semaphore is showing that all implementations of semaphore should be
> It is showing that semas (e.g. bin-semas aka "auto-reset events")
> are really error-prone. Their implementation of counting semaphore


> using a mutex (well, they actually use a totally brain-damaged
> "dying spinlock") plus a binary semaphore is buggy (it contains
> erroneous synchronization). Now... you might to follow this link:

Why buggy?

> "Pthreads win32 is just trying to be a general pupose condition
> variable as defined by the pthreads standard, suitable for any
> and all threads to go around calling pthread_cond_wait() and
> pthread_cond_signal() on. As a consequence the implementation
> contains several mutexes, semaphores etc, and a flow of control
> that will make your brains dribble out of your ears if you stare
> at the code too long (I have the stains on my collar to prove it
> ;-). Such are the joys of implementing condition variables using
> the Win32 synchronization primitives!"

But what's the relation between Microsoft implementation of semaphore,
pthread win32 implementation of condition and the error-proness of
semaphores versus mutexes/conditions in general?

Is it simply a mather of preference and style, or is there a simple case
to show why semaphores are error-prone instead of mutexes/conditions?

Nicolas Fleury

Boost list run by bdawes at, gregod at, cpdaniel at, john at