From owner-freebsd-alpha@FreeBSD.ORG Thu Aug 7 12:24:28 2003 Return-Path: Delivered-To: freebsd-alpha@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F2F9237B401; Thu, 7 Aug 2003 12:24:27 -0700 (PDT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3EEF643FBD; Thu, 7 Aug 2003 12:24:27 -0700 (PDT) (envelope-from marcel@xcllnt.net) Received: from athlon.pn.xcllnt.net (athlon.pn.xcllnt.net [192.168.4.3]) by ns1.xcllnt.net (8.12.9/8.12.9) with ESMTP id h77JOQwO046754; Thu, 7 Aug 2003 12:24:26 -0700 (PDT) (envelope-from marcel@piii.pn.xcllnt.net) Received: from athlon.pn.xcllnt.net (localhost [127.0.0.1]) by athlon.pn.xcllnt.net (8.12.9/8.12.9) with ESMTP id h77JOQWe000788; Thu, 7 Aug 2003 12:24:26 -0700 (PDT) (envelope-from marcel@athlon.pn.xcllnt.net) Received: (from marcel@localhost) by athlon.pn.xcllnt.net (8.12.9/8.12.9/Submit) id h77JOQAu000787; Thu, 7 Aug 2003 12:24:26 -0700 (PDT) (envelope-from marcel) Date: Thu, 7 Aug 2003 12:24:26 -0700 From: Marcel Moolenaar To: "Portante, Peter" Message-ID: <20030807192426.GC559@athlon.pn.xcllnt.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.4i cc: deischen@freebsd.org cc: alpha@freebsd.org Subject: Re: Atomic swap X-BeenThere: freebsd-alpha@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Alpha List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2003 19:24:28 -0000 On Thu, Aug 07, 2003 at 03:06:33PM -0400, Portante, Peter wrote: > Marcel, > > > atomic_swap_long(volatile long *dst, long val, long *res) > > { > > __asm ( "1: ldq_l t0,%0\n" > > " mov %1,t1\n" > > " stq_c t1,%0\n" > > " beq t1,1b\n" > > " stq t0,%3\n" ^^^^^^^^^^^^^^^^^^^^ Whoops, typo: %3 should be %2. > > :: "m"(*dst), "r"(val), "m"(*res) : "memory"); > > } > > > A word of caution on performing that stq without an MB before it: > another processor cannot read that location and the destination > location and assume anything about their contents based on what > they read unless an MB is between them. Good point. I don't think we have to worry about it, though. This function has a specific usage (see src/lib/libpthread/sys/lock.c). If I understand the code correctly, *res is never used other than the caller of atomic_swap_long that writes to *res. -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net