[Lazarus] thread safe
Andrew Brunner
andrew.t.brunner at gmail.com
Mon Jun 27 15:31:42 CEST 2011
On Mon, Jun 27, 2011 at 7:57 AM, Michael Schnell <mschnell at lumino.de> wrote:
> There is no question that we all agree about the technical background of all
> this.
Actually,
There was no mention of memory barriers other than the content in my
post. So if you want to understand what that is here is a link...
http://en.wikipedia.org/wiki/Memory_barrier
Simply protecting a loop with a futex is not sufficient. Assigning
variables in a multi-threaded environment is not sufficient.
Interlocked/Exchange/ExchangeAdd/Increment features must be used
whenever dealing with variables (with at least one exception) In my
experience arrays of boolean are atomic.
I ran tests on a HexCore AMD system which had unexplained anomalies
with pointers in an bidirectional linked list. I replaced all the
pointer assignments with InterlockedExchange and the system worked
flawlessly. Some of the assignments were taking place in a
criticalsection (btw).
More information about the Lazarus
mailing list