From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2003-10-18 11:33:42
Christophe Meessen wrote:
> It is an overkill for 32 bit values, but I just wanted to measure the
> mutex protection not the assignement operations.
Are you alluding to assignment being an atomic operation for 32 values ?
Even if that is true, locking is not redundant (and thus 'overkill'), as
locks provide 'memory barriers', which are a means for the system to flush
caches, and thus assure that all CPUs see the same value for the given
variable. Without such a tool, there's just no way to assure that the
value is written down from the CPU's register through the various
intermediate caches to a place that is shared among all CPUs.
Of course, if you know your hardware, you can optimize for that. But
here we are talking about portable programming...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk