diff options
author | dfr <dfr@FreeBSD.org> | 1998-09-16 09:27:05 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 1998-09-16 09:27:05 +0000 |
commit | 435b9d97a5dcb1684e7f8657b12906c0512fc419 (patch) | |
tree | 3f2170327c910ffa88d871fb19364ed40b98c283 /lib/libc_r | |
parent | 1bfc1a72e64434b1d9ac96129c9327afd0c88238 (diff) | |
download | FreeBSD-src-435b9d97a5dcb1684e7f8657b12906c0512fc419.zip FreeBSD-src-435b9d97a5dcb1684e7f8657b12906c0512fc419.tar.gz |
Change to a code sequence which is more likely to work on SMP systems.
Now all I need is an alpha SMP box to port FreeBSD to :-)
Diffstat (limited to 'lib/libc_r')
-rw-r--r-- | lib/libc_r/arch/alpha/_atomic_lock.S | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/lib/libc_r/arch/alpha/_atomic_lock.S b/lib/libc_r/arch/alpha/_atomic_lock.S index 7ca46f7..4a21fdf 100644 --- a/lib/libc_r/arch/alpha/_atomic_lock.S +++ b/lib/libc_r/arch/alpha/_atomic_lock.S @@ -19,7 +19,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: _atomic_lock.S,v 1.1 1998/04/29 09:36:03 jb Exp $ + * $Id: _atomic_lock.S,v 1.1 1998/06/09 08:21:55 jb Exp $ * */ @@ -35,23 +35,11 @@ LEAF(_atomic_lock,0) LDGP(pv) - /* Get the existing lock value and lock memory: */ - ldq_l v0, 0(a0) - - /* Branch if already locked: */ - bne v0, already_locked - - /* Not locked, so store 1: */ - mov 1, t0 - stq_c t0, 0(a0) - - /* Obtained the lock: */ - br done - -already_locked: - /* Already locked so put the value back and unlock memory: */ - stq_c v0, 0(a0) - -done: - RET +0: ldq_l v0, 0(a0) /* read existing lock value */ + mov 1, t0 /* locked value to store */ + stq_c t0, 0(a0) /* attempt to store, status in t0 */ + beq t0, 1f /* branch foward to optimise prediction */ + mb /* sync with other processors */ + RET /* return with v0==0 if lock obtained */ +1: br 0b /* loop to try again */ END(_atomic_lock) |