Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #1822
| Path | csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!gegeweb.org!news.buerger.net!newsfeed.datemas.de!eternal-september.org!feeder.eternal-september.org!feed.cnntp.org!news.cnntp.org!not-for-mail |
|---|---|
| From | Anthony Williams <anthony.ajw@gmail.com> |
| Newsgroups | comp.programming.threads |
| Subject | Re: forcing the compiler to reload from memory with c++0x |
| References | <4d3cee42$0$1209$426a74cc@news.free.fr> <1d21ad0a-db55-460e-aeb6-66f6d19369ea@i13g2000yqe.googlegroups.com> <4d3e2e3f$0$21517$426a34cc@news.free.fr> <4D40A4C7.16E6F9AE@web.de> <69d82db7-34be-4de7-86c4-2f39cc1e6df3@m13g2000yqb.googlegroups.com> <4d4221e9$0$17247$426a74cc@news.free.fr> <947b33d5-2509-4f0c-9256-a7c3de35578e@24g2000yqa.googlegroups.com> |
| Date | Fri, 28 Jan 2011 08:01:05 +0000 |
| Message-ID | <87mxmlxxry.fsf@justsoftwaresolutions.co.uk> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:mTV7Yp8GuMuPuezFTbPODoNeCds= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Lines | 31 |
| Organization | CNNTP |
| NNTP-Posting-Host | b6891469.read.cnntp.org |
| X-Trace | DXC=kj4>HDEdMCZIF90FU:O7kPWoT\PAgXa?QC]U8mjb]54^31?8ZVJ3gMUGj6PdB418W^f5ef5<?DV0_[MO?Yd5@9DV |
| X-Complaints-To | abuse@cnntp.org |
| Xref | csiph.com comp.programming.threads:1822 |
Show key headers only | View raw
frege <gottlobfrege@gmail.com> writes: > Now once you start talking C++0x, I don't *think* anything changes > (particularly since the standard tries to follow current practice, not > make up something new), but I can't actually quote chapter and verse > as to why. In particular, even though we code in it every day, it is > hard to say exactly what memory is, and thus what volatile does and > doesn't do, what the atomic ops do, etc - in a precise, technical- > standard kind of way. For me at least. In C++0x, if there are non-atomic accesses to an object from multiple threads, and at least one of them is a write then you have a "data race" and undefined behaviour. Volatile still has nothing to do with threading. If you don't think any ordering guarantees are required then use atomic operations with memory_order_relaxed. However, be aware that writes with relaxed operations can be reordered just like non-atomic writes, so you might well need a fence just to prevent the compiler reordering. If you are only using your fence to prevent compiler reordering then you can use atomic_signal_fence rather than atomic_thread_fence. The former is primarily a compiler directive, and will likely not issue any CPU instructions. 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 — Previous in thread | Find similar
Re: forcing the compiler to reload from memory with c++0x frege <gottlobfrege@gmail.com> - 2011-01-27 21:56 -0800
Re: forcing the compiler to reload from memory with c++0x Dmitriy Vyukov <dvyukov@gmail.com> - 2011-01-28 00:54 -0800
Re: forcing the compiler to reload from memory with c++0x Andy Venikov <swojchelowek@gmail.com> - 2011-01-28 15:28 -0500
Re: forcing the compiler to reload from memory with c++0x frege <gottlobfrege@gmail.com> - 2011-01-28 19:58 -0800
Re: forcing the compiler to reload from memory with c++0x Anthony Williams <anthony.ajw@gmail.com> - 2011-01-28 08:01 +0000
csiph-web