[Lazarus] thread safe

Michael Schnell mschnell at lumino.de
Mon Jun 27 17:14:44 CEST 2011


On 06/27/2011 04:58 PM, Andrew Brunner wrote:
> You're totally underestimating the need for a memory barrier :
While I do know that memory barriers are the way to go to avoid the 
expensive use of Mutex and friends, I am positive that an MB is not 
necessary if all accesses to something are protected by a Mutex, as same 
is designed to block any thread independently from the CPU it is running 
on. so no other thread can even try to access that memory location. (we 
are not discussing how to construct a Mutex/FUTEX internally).
> Focus on the "These primitives are usually implemented with the memory
> barriers ...
Yep, "usually" as critical sections are much more expensive.

-Michael





More information about the Lazarus mailing list