Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #1799

Re: forcing the compiler to reload from memory with c++0x

From Andy Venikov <swojchelowek@gmail.com>
Newsgroups comp.programming.threads
Subject Re: forcing the compiler to reload from memory with c++0x
Date 2011-02-06 23:17 -0500
Organization A noiseless patient Spider
Message-ID <iinrob$811$1@news.eternal-september.org> (permalink)
References (12 earlier) <iietha$f3a$1@news.eternal-september.org> <iifb30$9d3$1@news.eternal-september.org> <99c58954-6434-4135-b90a-da60dc1d865d@i14g2000prm.googlegroups.com> <iifuoj$1j3$1@news.eternal-september.org> <87wrlg9omp.fsf@justsoftwaresolutions.co.uk>

Show all headers | View raw


On 2/4/2011 3:42 AM, Anthony Williams wrote:
<snip>


>
> With the memory barriers as you've written here, this is not true: the
> acquire on the read of pLocalNext means that any changes written by the
> thread that wrote plocalCurrent->next must be visible to the current
> thread, including any writes to sharedHead. The compiler must thus
> re-read sharedHead, since a new value may have become visible.
>
> [New values written by threads other than the one that wrote
> pLocalCurrent->next need not be visible unless there is a transitive
> happens-before relationship]
>


Ok, I think I see what happenned.
Thanks for bearing with me.

I misread your posts as saying that for certain lock-free idioms you 
still would need volatile. When I was giving the examples, I was asking 
would these examples work with appropriate c++0x atomics/memory order. 
Your answer was to the examples as they were. And of course they 
wouldn't work as they were.

The bottom line is that the abstract machine should play nice with the 
semantics I give to the atomic stores and loads. I.e., we would not need 
volatile in c++0x (for threading). Yee-haa!

Thanks,
     Andy.

Back to comp.programming.threads | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: forcing the compiler to reload from memory with c++0x Andy Venikov <swojchelowek@gmail.com> - 2011-02-03 23:19 -0500
  Re: forcing the compiler to reload from memory with c++0x Andy Venikov <swojchelowek@gmail.com> - 2011-02-06 23:17 -0500
  Re: forcing the compiler to reload from memory with c++0x Anthony Williams <anthony.ajw@gmail.com> - 2011-02-04 09:21 +0000
  Re: forcing the compiler to reload from memory with c++0x Anthony Williams <anthony.ajw@gmail.com> - 2011-02-04 08:42 +0000
  Re: forcing the compiler to reload from memory with c++0x Joshua Maurice <joshuamaurice@gmail.com> - 2011-02-03 22:45 -0800
    Re: forcing the compiler to reload from memory with c++0x Joshua Maurice <joshuamaurice@gmail.com> - 2011-02-04 00:28 -0800

csiph-web