Date: Tue, 03 Dec 1996 08:42:04 +0100 From: Poul-Henning Kamp <phk@critter.tfs.com> To: Chris Csanady <ccsanady@friley216.res.iastate.edu> Cc: freebsd-smp@freebsd.org Subject: Re: spin locks... Message-ID: <3915.849598924@critter.tfs.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
In message <199612030654.AAA12221@friley216.res.iastate.edu>, Chris Csanady wri tes: >Its something we could use, so I thought I'd give it a shot. I thought it >would make a nice first assembly project, right? Yeah.. sure. I have never >been so frustrated with something so obviously simple. > >When I try to link it into a test program, it segfaults. The only way I >could obtain predictable behavior was to take out the cmpxchg and lock. > >Could someone please point out my error here? > >.text > .align 2,0x90 >.globl _get_spinlock >_get_spinlock: > pushl %eax > pushl %ecx > pushl %edx > movl _smp_active, %eax > cmpl $0, %eax + je 4 -> jne 1f -> jmp 4 >1: movl 4(%esp), %edx > movl $1, %ecx >2: lock > cmpxchg %ecx, (%edx) I can't remember, that lock may be implied in the cmpxchg instruction... Check out the smplock() I wrote and see what I do. -> je 3f -> jmp 4 + jne 4 >3: cmpl %ecx, (%edx) + jne 2b > je 3b I'm sure not, but where do you want to go then ? -> jmp 2b >4: popl %edx > popl %ecx > popl %eax > ret > >--Chris Csanady > > > -- Poul-Henning Kamp | phk@FreeBSD.ORG FreeBSD Core-team. http://www.freebsd.org/~phk | phk@login.dknet.dk Private mailbox. whois: [PHK] | phk@tfs.com TRW Financial Systems, Inc. Power and ignorance is a disgusting cocktail.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3915.849598924>