Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Alexander Terekhov Newsgroups: comp.programming.threads Subject: Re: Interlocked operations, volatile Date: Thu, 14 Jul 2011 23:05:36 +0200 Organization: A noiseless patient Spider Lines: 25 Message-ID: <4E1F5A20.2568A5DD@web.de> References: <99a57186-cf9f-47ee-8955-07df1ce2b126@b21g2000yqc.googlegroups.com> <288515a0-5802-4f15-949c-38a901af2fa8@r11g2000prd.googlegroups.com> <6f742fb4-cb39-4b56-b062-4eeb1e51ebdb@h25g2000prf.googlegroups.com> <3806a754-4ec5-4e71-be4d-318db1760557@u24g2000prn.googlegroups.com> <7232157d-7a0a-43e6-8462-dca56a861dd0@t9g2000vbs.googlegroups.com> Reply-To: terekhov@web.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="MCbSEzW5qwGLFMNXJh39IQ"; logging-data="28747"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/d6LkXQlcPFbzX1v/9LoLqr/cpjAnacco=" X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en Cancel-Lock: sha1:Gx5aVAsK3gMZih5NkZLDENXMIUo= Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:443 David Schwartz wrote: > > On Jul 14, 8:52 am, Andrew Che wrote: > > > Couldn't You give an (C++) example that demonstrates difference > > between: > > 1) concurrent write with locks and read WITH locks > > 2) concurrent write with locks and read WITHOUT locks > > > I mean I would like to see a program that prints something like "a" in > > case 1) and "aaaa" in case 2) because races are. > > Not really. C++ provides no way to have concurrent flows of execution. Upcomming C++11 does provide threading... > And whatever scheme we use to have concurrent flows of execution will > also include rules that prohibit concurrent write and read without > locks. ... and atomics (concurrent write and read without locks allowed). regards, alexander.