From 1624bd730357186fd3f82d6daca821cdf3c638dc Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Wed, 16 Sep 1998 09:27:05 +0000 Subject: [PATCH] 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 :-) --- lib/libc_r/arch/alpha/_atomic_lock.S | 28 ++++++------------- .../arch/alpha/alpha/_atomic_lock.S | 28 ++++++------------- 2 files changed, 16 insertions(+), 40 deletions(-) diff --git a/lib/libc_r/arch/alpha/_atomic_lock.S b/lib/libc_r/arch/alpha/_atomic_lock.S index 7ca46f782347..4a21fdf1abc4 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) diff --git a/lib/libpthread/arch/alpha/alpha/_atomic_lock.S b/lib/libpthread/arch/alpha/alpha/_atomic_lock.S index 7ca46f782347..4a21fdf1abc4 100644 --- a/lib/libpthread/arch/alpha/alpha/_atomic_lock.S +++ b/lib/libpthread/arch/alpha/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)