|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-02-11 13:18:32
From: "Wyss, Felix" <felixw_at_[hidden]>
> > I'd love to simply use a pthread_mutex/CRITICAL_SECTION (a critical
section
> > is a 'foolproof spinlock', it spins for a while, then falls back to a
mutex)
> > but people were (are) concerned about their efficiency.
>
> That is correct, but the Win32 CRITICAL_SECTION structure uses 24 bytes
compared to 4 bytes for a simple atomic-exchange based spin-lock. As for
efficiency: unless there is a lot of contention, I would expect two atomic
exchanges to incur the same overhead as two atomic increment/decrement
operations (as in the current implementation of counted_base).
<
If that's true, why do people bother with critical sections and pthread
mutexes instead of simply using spinlocks? :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk