Date: Thu, 7 Aug 2003 12:24:26 -0700 From: Marcel Moolenaar <marcel@xcllnt.net> To: "Portante, Peter" <peter.portante@hp.com> Cc: alpha@freebsd.org Subject: Re: Atomic swap Message-ID: <20030807192426.GC559@athlon.pn.xcllnt.net> In-Reply-To: <B24FABB430F7C94D942D6386447C93DC0512B560@tayexc17.americas.cpqcorp.net> References: <B24FABB430F7C94D942D6386447C93DC0512B560@tayexc17.americas.cpqcorp.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030807192426.GC559>