Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.datemas.de!feed.cnntp.org!news.cnntp.org!not-for-mail From: Anthony Williams Newsgroups: comp.programming.threads Subject: Re: questions about memory_order_seq_cst fence References: <43eb372b-6517-4914-b647-860f1f7136ba@k15g2000pri.googlegroups.com> <87boxyfctc.fsf@justsoftwaresolutions.co.uk> <4DF9D581.E607BEB4@web.de> <8739jaf59n.fsf@justsoftwaresolutions.co.uk> <4DF9EF9A.911CC74F@web.de> <87wrgm9bxk.fsf@justsoftwaresolutions.co.uk> <4DFA18D0.3A413EED@web.de> <87oc1xajr3.fsf@justsoftwaresolutions.co.uk> <4DFA2342.52931D8@web.de> <87k4clai0h.fsf@justsoftwaresolutions.co.uk> Date: Thu, 16 Jun 2011 17:07:28 +0100 Message-ID: <87boxxahfj.fsf@justsoftwaresolutions.co.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:KO3AplnhWLXGoHUDoEeKUdJ23z4= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 41 Organization: CNNTP NNTP-Posting-Host: 22d84dbe.read.cnntp.org X-Trace: DXC=n6k5K0?M0D;=]STOcIHgj;WoT\PAgXa?1=oT3jZUB0e931?8ZVJ3gM5Gj6PdB418W>gfGPN5SUeJ10MX\S9GSo72 X-Complaints-To: abuse@cnntp.org Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:309 "Chris M. Thomasson" writes: > "Anthony Williams" wrote in message > news:87k4clai0h.fsf@justsoftwaresolutions.co.uk... >> Alexander Terekhov writes: >> >>> Anthony Williams wrote: > [....] >>>> Can you give an example that would be broken by the lack of such a >>>> constraint, >>> >>> Any code written with the expectation that >>> >>> x.store(44, memory_order_relaxed); // or _release >>> r1 = y.load(memory_order_seq_cst); >>> >>> is the same as >>> >>> x.store(44, memory_order_relaxed); // or _release >>> atomic_thread_fence(memory_order_seq_cst); >>> r1 = y.load(memory_order_relaxed); // or _acquire/_consume >> >> Can you give a specific example of such code? > > Perhaps in an SMR implementation. The author would be screwed if he/she > thinks that the seq_cst load to `y' means that it will not be reordered with > the preceding store to `x'. If you rely on things that aren't true, then you end up in a mess ;-) I'd better expand my question: Can you give an example of such code, along with reasoning based on the C++0x memory model to show that it is not broken? 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