Re: Am I or Alexandrescu wrong about singletons?
On Mar 26, 12:25 am, "Leigh Johnston" <le...@i42.co.uk> wrote:
"George Neuner" <gneun...@comcast.net> wrote in message
news:rq1nq5tskd51cmnf585h1q2elo28euh2kn@4ax.com...
<snip>
'volatile' is necessary for certain uses but is not sufficient for
(al)most (all) uses. I would say that for expert uses, some are
portable and some are not. For non-expert uses ... I would say that
most uses contemplated by non-experts will be neither portable nor
sound.
Whether or not the store that is guaranteed to be emitted by
the compiler due to the presence of volatile propagates to L1
cache, L2 cache or main memory is irrelevant as far as
volatile and multi-threading is concerned as long as CPU
caches remain coherent.
That depends on the architecture and what the compiler actually
does in the case of volatile. Some of the more recent
processors have a separate cache for each core, at least at the
lowest level, and most access memory through a pipeline which is
unique to the core.
You could argue that because of this volatile is actually more
useful for multi-threading than for its more traditional use
of performing memory mapped I/O with modern CPU architectures.
You'll have to explain that, since none of the compilers I use
generate any sort of fence or membar when volatile is used, and
the processors definitely require it,
--
James Kanze
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]