Date: Tue, 03 Dec 1996 15:08:32 -0600 From: Chris Csanady <ccsanady@friley216.res.iastate.edu> Cc: freebsd-smp@freebsd.org Subject: Finished locks.. Message-ID: <199612032108.PAA15610@friley216.res.iastate.edu> In-Reply-To: Your message of Tue, 03 Dec 1996 00:54:40 -0600. <199612030654.AAA12221@friley216.res.iastate.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
For what it's worth, I have completed a simple implementation of spin locks. (However, I'm sure someone will tell me different.. :) Either way, it was nice to learn a bit of assembly. If these are not sufficient, how can I improve upon them? I'd like to move some of the locking around, and they would help. In particular, I am planning to move the global lock out into the syscalls, and perhaps create a seperate lock for the run queues and such. Then from there, we can we can reduce the graininess a bit. :) Anyway, I'd just like to thank all of you for helping me out. Chris .text /*********************************************************************** * void LOCK() * ----------------- * All registers preserved */ .align 2,0x90 .globl _LOCK _LOCK: pushl %eax pushl %ecx pushl %edx movl $_smp_active, %eax cmpl $0, %eax je 4f 1: movl 16(%esp), %edx movl $1, %ecx movl $0, %eax 2: lock cmpxchg %ecx, (%edx) jne 3f jmp 4f 3: cmpl %ecx, (%edx) je 3b jmp 2b 4: popl %edx popl %ecx popl %eax ret /*********************************************************************** * int TRY_LOCK() * ----------------- * reg %eax == 1 if success */ .align 2,0x90 .globl _TRY_LOCK _TRY_LOCK: pushl %ecx pushl %edx movl $_smp_active, %eax cmpl $0, %eax je 1f movl 12(%esp), %edx movl $1, %ecx movl $0, %eax lock cmpxchg %ecx, (%edx) jne 1f movl $1, %eax jmp 2f 1: movl $0, %eax 2: popl %edx popl %ecx ret /*********************************************************************** * void UNLOCK() * ----------------- * All registers preserved */ .align 2,0x90 .globl _UNLOCK _UNLOCK: pushl %ecx movl 8(%esp), %ecx movl $0, (%ecx) popl %ecx ret
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612032108.PAA15610>