<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 06/27/2011 03:31 PM, Andrew Brunner wrote:<br>
    <blockquote
      cite="mid:BANLkTimjmyJBWQp6c2_T4jFYuvq50g4Xgg@mail.gmail.com"
      type="cite">
      <pre wrap="">
Simply protecting a loop with a futex is not sufficient.  Assigning
variables in a multi-threaded environment is not sufficient.
</pre>
    </blockquote>
    While I don't think we should this discuss in this context, I
    suggest that in the docs for the user of the object library (that
    was the starting point of the discussion), any type of thread-safety
    should include threads running on multiple processors.<br>
    <blockquote
      cite="mid:BANLkTimjmyJBWQp6c2_T4jFYuvq50g4Xgg@mail.gmail.com"
      type="cite">
      <pre wrap="">
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.
</pre>
    </blockquote>
    Yep. But this is only relevant if you don't protect them by a
    critical section, as this excludes concurrent exchange before the
    critical instructions are executed. Of course (when possible) using
    the interlocked instruction results in a lot less overhead than
    simply using a critical section.<br>
    <blockquote
      cite="mid:BANLkTimjmyJBWQp6c2_T4jFYuvq50g4Xgg@mail.gmail.com"
      type="cite">
      <pre wrap="">
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. </pre>
    </blockquote>
    This is clear. You also would have been able to avoid the problem by
    using critical sections around <b>all </b>the appropriate
    instructions, but supposedly this would have slowed done the
    application greatly. <br>
    <blockquote
      cite="mid:BANLkTimjmyJBWQp6c2_T4jFYuvq50g4Xgg@mail.gmail.com"
      type="cite">
      <pre wrap=""> Some of the assignments were taking place in a
criticalsection (btw).
</pre>
    </blockquote>
    I believe that the "some" were not enough.<br>
    <br>
    -Michael<br>
  </body>
</html>