Re: [eigen] Help on solving a race condition |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
static std::ptrdiff_t m_l1CacheSize = 0; static std::ptrdiff_t m_l2CacheSize = 0; static bool initialized = false; if(!initialized)
....
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
....There is also quite a good explanation of these things at http://en.cppreference.com/w/cpp/atomic/memory_order Pre C++11 behavior seems to be memory_order_relaxed but without atomic variables so pretty much anything goes. A concrete example:
t1 sees initialize == false and does m_l1CacheSize = manage_caching... .... initialized = true; "after" that t2 does m_l1CacheSize = 0; .... but already sees initialized == true; resulting (possibly) in obviously wrong sizes of 0. Ilja
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |