Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-06-06 07:03:13


>It seems to me that having all these operations
(read/write/add/test&set/exchange) is a bit overkill. What's wrong
with just a plain old mutex (with lock/unlock). Is there that much of
a performance difference to be gained?

Well here's the performance comparison from MSDN:

Table 1. Comparison times when incrementing a counter.

regular memory variable: 31.25 nanoseconds
atomic counter: 178.1 nanoseconds
critical section: 504.6 nanoseconds

So an atomic increment is about 4x faster than a critical section.

The problem with emulation is this: if an operation can be implemented with
two atomic ops or one mutex which should be used? If the atomic ops are
emutated then the answer is different than if they're not.

- John.

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