Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6782
| From | Anthony Williams <anthony.ajw@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Threading question - read-read coherency almost, sort of, with seq_cst fences |
| References | <c4891256-0c18-4eab-a227-ba819263d133@v11g2000prk.googlegroups.com> |
| Date | 2011-06-16 09:42 +0100 |
| Message-ID | <877h8mf9ps.fsf@justsoftwaresolutions.co.uk> (permalink) |
| Organization | CNNTP |
Joshua Maurice <joshuamaurice@gmail.com> writes: > Consider the following code. > > /*** code 1 ***/ > // Initially > atomic<int> x(0), y(0); > > // Thread 1: > y.store(1, memory_order_release); > atomic_thread_fence(memory_order_seq_cst); //fence 1 > r1 = x.load(memory_order_acquire); > > // Thread 2: > x.store(1, memory_order_release); > > // Thread 3: > r2 = x.load(memory_order_acquire); > atomic_thread_fence(memory_order_seq_cst); //fence 3 > r3 = y.load(memory_order_acquire); > /***************/ > > Q1. First, am I right in concluding that in the above code, all of the > loads and stores might as well be memory_order_relaxed, right? Yes. > Q2. Second, is the following end condition possible? > r1 == 0 && r2 == 1 && r3 == 0 Yes. > Anthony Williams in the comp.programming.threads (who is apparently on > the concurrency working group), initially had a different > interpretation. I just reread it several times, and I'm not quite sure > what he's trying to say. He initially thought that you can use it > directly to prove that NOT (r1 == 0 && r2 == 1). But I now believe I'm mistaken. After checking my notes, we discussed requiring that seq_cst fences ordered loads as in this example, but decided against it. 29.3p7 is intended to apply only to writes. 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.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Threading question - read-read coherency almost, sort of, with seq_cst fences Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-15 16:56 -0700
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences "Chris M. Thomasson" <cristom@charter.net> - 2011-06-16 00:28 -0700
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences "Chris M. Thomasson" <cristom@charter.net> - 2011-06-16 00:41 -0700
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-16 02:47 -0700
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences Anthony Williams <anthony.ajw@gmail.com> - 2011-06-16 11:45 +0100
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences "Chris M. Thomasson" <cristom@charter.net> - 2011-06-16 14:32 -0700
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences Anthony Williams <anthony.ajw@gmail.com> - 2011-06-16 09:42 +0100
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-16 02:50 -0700
Re: Threading question - read-read coherency almost, sort of, with seq_cst fences Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-16 02:53 -0700
csiph-web