|Re: [eigen] Help on solving a race condition|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Help on solving a race condition
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Mon, 11 Jun 2012 22:00:04 +0200
- Cc: Paul Tucker <tucker@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=kgja2rwNNVB6zESbY6SXXDYrtLFaE9OkjZE4+JEJ+oE=; b=ttnxB1rsaCVW5KAhTGvDBcnx4ejr1NY16gF8kIUOuYoWKRsc1xu39v8Tysf8y9I4SO 3jUamWXQTBmTZDT0Jl3xORWu5j8WxCnL2Q8dpHw7johhXx2emkpPdXbMjlMDO4CyxHYP tmuq8LHZdoYxK/PiEmR/bJjoZoc46oi5KSZMnHWckz0CmRYyo8/tq+BYo9KA0d4OE+hw MechfnKvzoFMxV7rWXRhK6uA/bC1ThCIzw4JcIOQgKlIkeJNN6BkteUvI6ZEL06OAT+Z +B0ifQcSu5df40RyZAnIY4tNr7nkTV2fGQ+oiwxHdeww+h66jhdOW8atyRWQXv41mSwA 3TTQ==
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.
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.