none
Synchronization and Multiprocessor Issues RRS feed

  • Question

  • Hi,

    I've carrefullly read the Synchronization and Multiprocessor Issues msdn documentation and I'm wondering something about the "interlocked" solution to the "Fixing race condition" sample. From my understanding, Interlocked function are full memory barriers. It means that it both tells the compiler not to reorder the code around the barrier and the processor to flush cache lines (basically). So, why is the "iValue" accessed with an interlocked function? I mean, the "fValueHasBeenComputed" is used as a synchronization primitive and it is modified using interlocked functions which ensure the memory barrier functionnality. So I think "iValue" could be freelly accessed (without any interlock function) as lon as synchronization is done with interlocked functions, isn't it?

    Am I wrong?

    Many thanks
    Guillaume
    vendredi 8 juin 2007 11:47