From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14942 invoked by alias); 26 Oct 2007 15:51:12 -0000 Received: (qmail 14932 invoked by uid 22791); 26 Oct 2007 15:51:11 -0000 X-Spam-Check-By: sourceware.org Received: from ug-out-1314.google.com (HELO ug-out-1314.google.com) (66.249.92.173) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 26 Oct 2007 15:51:08 +0000 Received: by ug-out-1314.google.com with SMTP id o38so750759ugd for ; Fri, 26 Oct 2007 08:51:05 -0700 (PDT) Received: by 10.67.96.16 with SMTP id y16mr991035ugl.1193413865169; Fri, 26 Oct 2007 08:51:05 -0700 (PDT) Received: from moonlight.home ( [80.246.71.156]) by mx.google.com with ESMTPS id w5sm7178264mue.2007.10.26.08.51.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 26 Oct 2007 08:51:04 -0700 (PDT) Received: from moonlight.home (localhost.localdomain [127.0.0.1]) by moonlight.home (Postfix) with ESMTP id F2CE83A7C7; Fri, 26 Oct 2007 19:51:01 +0400 (MSD) Received: (from tomash@localhost) by moonlight.home (8.13.1/8.13.1/Submit) id l9QFp1HQ016925; Fri, 26 Oct 2007 19:51:01 +0400 Date: Fri, 26 Oct 2007 15:51:00 -0000 From: Tomash Brechko To: Ian Lance Taylor Cc: Bart Van Assche , gcc@gcc.gnu.org Subject: Re: Optimization of conditional access to globals: thread-unsafe? Message-ID: <20071026155101.GB5041@moonlight.home> References: <20071026143334.GA5041@moonlight.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2007-10/txt/msg00485.txt.bz2 On Fri, Oct 26, 2007 at 08:32:07 -0700, Ian Lance Taylor wrote: > The language standard does not forbid speculative stores to non-atomic > objects. That's why there's a proposal to refine the language. I was meaning the folloing: http://www.artima.com/cppsource/threads_meeting.html: Hans Boehm and Herb Sutter both presented very detailed and well-thought out memory models. Their differences are subtle and important, but in broad strokes, both proposals paint a similar picture. In particular, both proposals: * Specify a set of atomic (aka, interlocked) primitive operations. * Explicitly specify the ordering constraints on atomic reads and writes. * Specify the visibility of atomic writes. * Disallow speculative stores on potentially shared objects. * Disallow reading and re-writing of unrelated objects. (For instance, if you have struct S{ char a,b; }; it is not OK to modify b by reading in the whole struct, bit-twiddling b, and writing the whole struct because that would interfere with another thread that is trying to write to a.) So, will "potentially shared objects" be marked as such explicitly by the programmer, or is it a compiler job to identify them? -- Tomash Brechko