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: ittium Newsgroups: comp.programming.threads Subject: Re: Threads and statically allocated buffer Date: Sun, 25 Sep 2011 11:45:44 +0530 Organization: A noiseless patient Spider Lines: 18 Message-ID: References: <3b791257-790b-43e2-a447-4fcc33538138@a3g2000pro.googlegroups.com> <553ba480-a945-4ab9-879a-1a0cfaa70f31@n36g2000yqb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 25 Sep 2011 06:15:46 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="bJjJws9BHOrKDnmGuiN+3Q"; logging-data="15051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184pnyCGNWCP3uuQU/O4VqG" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 In-Reply-To: <553ba480-a945-4ab9-879a-1a0cfaa70f31@n36g2000yqb.googlegroups.com> Cancel-Lock: sha1:i+Ku0Y0fuigIlWp76QFUTzUEBDs= Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:605 On 25-09-2011 AM 01:12, David Schwartz wrote: > On Sep 23, 9:38 pm, ittium wrote: > >> Is there any operation that is guaranteed to be atomic ? > > Your platform might have some. > >> From your >> reasoning it seems operations like ++a or a=b are also not atomic. > > Exactly. Some CPUs don't even have atomic increment operations. And > even if the CPU does, the compiler might see that it needs the value > later and prefer to have it in a register, so it might not use an > atomic in-memory increment even if it has one. You are saying even if there is some atomic operation available for some compiler+OS+CPU, this is not guaranteed to be portable, In other words, there is no portable atomic operation.