Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2003 15:15:49 -0400
From:      "Portante, Peter" <peter.portante@hp.com>
To:        <deischen@freebsd.org>
Cc:        Marcel Moolenaar <marcel@xcllnt.net>
Subject:   RE: Atomic swap
Message-ID:  <B24FABB430F7C94D942D6386447C93DC0512B562@tayexc17.americas.cpqcorp.net>

next in thread | raw e-mail | index | archive | help
> > > static __inline void
> > > atomic_swap_long(volatile long *dst, long val, long *res)
> > > {
> > > 	__asm (	"1: ldq_l   t0,%0\n"
> > > 		"   mov     %1,t1\n"
> >=20
> > If I swap the first 2 instructions:
> >=20
> > 	__asm ( "1: mov     %1,t1\n"
> > 		    ldq_l   t0,%0\n"
> >=20
> > that eliminates 1 instruction from between the locked
> > instructions.  Is there anything wrong with doing that?
> >=20
> Actually, the processor has a chance to do something while waiting for =
memory, so it does not hurt to have the mov inside the ldq_l/stq_c pair.
>=20
And you should also consider that when the code loops, you want to issue =
the memory operation as soon as possible, which means performing the mov =
after the ldq_l.

-Peter



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B24FABB430F7C94D942D6386447C93DC0512B562>