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 :-)
This commit is contained in:
Doug Rabson 1998-09-16 09:27:05 +00:00
parent 9fe6a96a87
commit 1624bd7303
2 changed files with 16 additions and 40 deletions

View File

@ -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)

View File

@ -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)