Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Dec 1996 15:21:32 +0800
From:      Peter Wemm <peter@spinner.dialix.com>
To:        Chris Csanady <ccsanady@friley216.res.iastate.edu>
Cc:        freebsd-smp@freebsd.org
Subject:   Re: spin locks... 
Message-ID:  <199612030721.PAA01103@spinner.DIALix.COM>
In-Reply-To: Your message of "Tue, 03 Dec 1996 00:54:40 CST." <199612030654.AAA12221@friley216.res.iastate.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
Chris Csanady wrote:
>         pushl   %eax
>         pushl   %ecx
>         pushl   %edx
>         movl    _smp_active, %eax
>         cmpl    $0, %eax
>         jne     1f
>         jmp     4
> 1:      movl    4(%esp), %edx
>         movl    $1, %ecx
> 2:      lock
>         cmpxchg %ecx, (%edx)
>         je      3f
>         jmp     4
> 3:      cmpl    %ecx, (%edx)
[ ... ]

You've been bitten by Intel's assembler syntax....  cmpxchg actually
has three arguments, %eax is implicit.

The way it really works..  Given:  lock; cmpxchg %ecx, (%edx), what happens
is that if %eax == (%edx), it exchanges (%edx) with %ecx.

ie: %eax is what you hope that it is currently set to, and %ecx is the new
value if you don't loose a race.

-Peter



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