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


Groups > comp.programming.threads > #1806

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

From Anthony Williams <anthony.ajw@gmail.com>
Newsgroups comp.programming.threads
Subject Re: forcing the compiler to reload from memory with c++0x
References (2 earlier) <4d3e2e3f$0$21517$426a34cc@news.free.fr> <4D40A4C7.16E6F9AE@web.de> <69d82db7-34be-4de7-86c4-2f39cc1e6df3@m13g2000yqb.googlegroups.com> <4D415CB9.8E64A6AE@web.de> <0f5da3b3-9991-4f19-bc5e-8462b1a9feef@a28g2000vbo.googlegroups.com>
Date 2011-01-28 08:12 +0000
Message-ID <87ei7xxx9f.fsf@justsoftwaresolutions.co.uk> (permalink)
Organization CNNTP

Show all headers | View raw


frege <gottlobfrege@gmail.com> writes:

> On Jan 27, 6:53 am, Alexander Terekhov <terek...@web.de> wrote:
>> frege wrote:
>>
>> [...]
>>
>> > Anyhow, I would say that this is one of those rare cases where
>> > volatile is the right answer - you just need to adds lots of code
>>
>> Volatile is not the right answer. atomic<> is the rights answer.
>>
>
> Yes, we still need atomic - in the most basic sense - ie an aligned
> int, for example.  But no memory_order_* instructions are needed.

Well, if you use an atomic<int> then you will need to use
memory_order_relaxed explicitly unless you want the default
memory_order_seq_cst.

If you don't use atomic<int> then you have undefined behaviour.

Anthony
-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

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


Thread

Re: forcing the compiler to reload from memory with c++0x Anthony Williams <anthony.ajw@gmail.com> - 2011-01-28 08:12 +0000
  Re: forcing the compiler to reload from memory with c++0x frege <gottlobfrege@gmail.com> - 2011-01-28 19:47 -0800
    Re: forcing the compiler to reload from memory with c++0x Dmitriy Vyukov <dvyukov@gmail.com> - 2011-01-29 01:43 -0800

csiph-web