Re: [eigen] Help on solving a race condition

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Thanks a lot, that's the kind of explanations I expected.


So I'm afraid the only truly portable and robust solution will be to
add an initialize function.


Gael.



On Mon, Jun 11, 2012 at 7:43 PM, John Tytgat <John.Tytgat@xxxxxxxx> wrote:
> There is no guarantee that the "initialized = true" gets seen by another
> thread after the update to "m_l1CacheSize" or "m_l2CacheSize" gets seen by
> that thread.  The order of the stores can be differently perceived by the
> other thread than what the first thread did.  And this because your compiler
> can have rearranged your "initialized" store before the stores to
> "m_l1CacheSize" and "m_l2CacheSize".  Moreover, another store rearrangement
> can happen at runtime in the memory system between CPU, all its caches and
> main memory.
>
> Or it could very well be that updates to "initialized", "m_l1CacheSize" or
> "m_l2CacheSize" are never seen by other threads (as e.g. the update sticks
> at a certain cache level which is not shared by other threads).
>
> Before someone suggests to additionally use the volatile keyword, volatile
> will make the compiler respect the store order but your memory system can
> still do reordering (cfr.
> http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/).
>
> John.
>
>
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/