Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbWIHV0G (ORCPT ); Fri, 8 Sep 2006 17:26:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751212AbWIHV0G (ORCPT ); Fri, 8 Sep 2006 17:26:06 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:16389 "HELO iolanthe.rowland.org") by vger.kernel.org with SMTP id S1751206AbWIHV0D (ORCPT ); Fri, 8 Sep 2006 17:26:03 -0400 Date: Fri, 8 Sep 2006 17:26:01 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Oliver Neukum cc: paulmck@us.ibm.com, David Howells , Kernel development list Subject: Re: Uses for memory barriers In-Reply-To: <200609082230.22225.oliver@neukum.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 830 Lines: 31 On Fri, 8 Sep 2006, Oliver Neukum wrote: > It seems you are correct. > Therefore the correct code on CPU 1 would be: > > y = -1; > b = 1; > //mb(); > //x = a; > while (y < 0) relax(); > > mb(); > x = a; > > assert(x==1 || y==1); //??? > > And yes, it is confusing. I've been forced to change my mind twice. Again you have misunderstood. The original code was _not_ incorrect. I was asking: Given the code as stated, would the assertion ever fail? The code _was_ correct for my purposes, namely, to illustrate a technical point about the behavior of memory barriers. Alan - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/