From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10759 invoked by alias); 28 Oct 2007 17:26:09 -0000 Received: (qmail 10749 invoked by uid 22791); 28 Oct 2007 17:26:09 -0000 X-Spam-Check-By: sourceware.org Received: from ch-smtp02.sth.basefarm.net (HELO ch-smtp02.sth.basefarm.net) (80.76.149.213) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 28 Oct 2007 17:26:06 +0000 Received: from c83-253-25-183.bredband.comhem.se ([83.253.25.183]:56730 helo=falcon.midgard.homeip.net) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1ImBtj-00069Y-6V for gcc@gcc.gnu.org; Sun, 28 Oct 2007 18:26:03 +0100 Received: (qmail 7005 invoked from network); 28 Oct 2007 17:59:17 +0100 Received: from owl.midgard.homeip.net (10.1.5.7) by falcon.midgard.homeip.net with ESMTP; 28 Oct 2007 17:59:17 +0100 Received: (qmail 19434 invoked by uid 1001); 28 Oct 2007 17:59:17 +0100 Date: Sun, 28 Oct 2007 17:29:00 -0000 From: Erik Trulsson To: Dave Korn Cc: 'Bart Van Assche' , 'Florian Weimer' , 'Andrew Haley' , gcc@gcc.gnu.org, 'Andrew Pinski' , 'Tomash Brechko' , 'Robert Dewar' Subject: Re: Optimization of conditional access to globals: thread-unsafe? Message-ID: <20071028165917.GA19392@owl.midgard.homeip.net> Mail-Followup-To: Dave Korn , 'Bart Van Assche' , 'Florian Weimer' , 'Andrew Haley' , gcc@gcc.gnu.org, 'Andrew Pinski' , 'Tomash Brechko' , 'Robert Dewar' References: <18210.795.425145.46885@zebedee.pink> <87hckcpvp5.fsf@mid.deneb.enyo.de> <87abq4ofym.fsf@mid.deneb.enyo.de> <02a401c81973$bd1a73e0$2e08a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02a401c81973$bd1a73e0$2e08a8c0@CAM.ARTIMI.COM> User-Agent: Mutt/1.5.16 (2007-06-09) X-Scan-Result: No virus found in message 1ImBtj-00069Y-6V. 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/msg00622.txt.bz2 On Sun, Oct 28, 2007 at 03:03:46PM -0000, Dave Korn wrote: > On 28 October 2007 13:32, Bart Van Assche wrote: > > > Requiring that all > > thread-shared variables should be declared volatile is completely > > unacceptable. > > Any variable that may be altered by an external unpredictable asynchronous > 'force majeure' must be declared volatile or the behaviour is undefined. Your > code is simply incorrect, and you appear to be demanding that the language > standards and the compiler all be revised to make the buggy code valid. Unfortunately it seems that the POSIX standard for threads say that as long as access to a shared variable is protected by a mutex there is no need to use 'volatile'. This means that POSIX essentially defines certain behaviours that the C standard left undefined. Personally I think the POSIX standard is broken in this regard, but if programs that are valid according to POSIX are to work correctly then it is not sufficient for the compiler to follow the C standard. It must also not break any of the guarantees that POSIX makes. > > > We need a solution today for the combination of C/C++ > > and POSIX threads, we can't wait for the respective language > > standardization committees to come up with a solution. > > You already have it, but you have declared it "unacceptable" and refused to > use it without stating any clear reason. > > cheers, > DaveK > -- > Can't think of a witty .sigline today.... > -- Erik Trulsson ertr1013@student.uu.se