From owner-freebsd-arch Sat Mar 22 11:49:21 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D16A637B401 for ; Sat, 22 Mar 2003 11:49:20 -0800 (PST) Received: from magic.adaptec.com (magic-mail.adaptec.com [208.236.45.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D5CD43FBD for ; Sat, 22 Mar 2003 11:49:20 -0800 (PST) (envelope-from gibbs@scsiguy.com) Received: from redfish.adaptec.com (redfish.adaptec.com [162.62.50.11]) by magic.adaptec.com (8.11.6/8.11.6) with ESMTP id h2MJmSl09193; Sat, 22 Mar 2003 11:48:28 -0800 Received: from btc.btc.adaptec.com (btc.btc.adaptec.com [10.100.0.52]) by redfish.adaptec.com (8.8.8+Sun/8.8.8) with ESMTP id LAA06908; Sat, 22 Mar 2003 11:48:44 -0800 (PST) Received: from [10.100.253.70] (aslan [10.100.253.70]) by btc.btc.adaptec.com (8.8.8+Sun/8.8.8) with ESMTP id MAA06657; Sat, 22 Mar 2003 12:48:38 -0700 (MST) Date: Sat, 22 Mar 2003 12:48:39 -0700 From: "Justin T. Gibbs" Reply-To: "Justin T. Gibbs" To: Poul-Henning Kamp , Bakul Shah Cc: arch@freebsd.org Subject: Re: memcpy() with specified direction of copying ? Message-ID: <8980000.1048362518@aslan.btc.adaptec.com> In-Reply-To: <9531.1047848405@critter.freebsd.dk> References: <9531.1047848405@critter.freebsd.dk> X-Mailer: Mulberry/3.0.2 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > Well, in my case it is a matter of shared memory where the order in > which I snapshot a data structure is critical for detecting integrity > issues. Without memory barriers, the order is undefined on many cpus irrespective of the direction of copy. So, for a data structure like this: start_tag some data ... end_tag A client knows that the data is stable if start_tag and end_tag are equal only if the data is written as: start_tag = new_tag; mb(); Fill the middle in whatever order is convenient; mb(); end_tag = new_tag; -- Justin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message