From owner-freebsd-smp Wed Dec 4 07:29:46 1996 Return-Path: owner-smp Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id HAA14619 for smp-outgoing; Wed, 4 Dec 1996 07:29:46 -0800 (PST) Received: from tfs.com (tfs.com [140.145.250.1]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id HAA14605 for ; Wed, 4 Dec 1996 07:29:42 -0800 (PST) Received: from critter.tfs.com by tfs.com (smail3.1.28.1) with SMTP id m0vVIYx-0003wHC; Wed, 4 Dec 96 06:44 PST Received: from critter.tfs.com (localhost [127.0.0.1]) by critter.tfs.com (8.8.2/8.8.2) with ESMTP id JAA01938; Wed, 4 Dec 1996 09:33:34 +0100 (MET) To: Chris Csanady cc: freebsd-smp@freebsd.org Subject: Re: Finished locks.. In-reply-to: Your message of "Tue, 03 Dec 1996 15:08:32 CST." <199612032108.PAA15610@friley216.res.iastate.edu> Date: Wed, 04 Dec 1996 09:33:34 +0100 Message-ID: <1936.849688414@critter.tfs.com> From: Poul-Henning Kamp Sender: owner-smp@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In message <199612032108.PAA15610@friley216.res.iastate.edu>, Chris Csanady wri tes: >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 + je 4f >3: cmpl %ecx, (%edx) > je 3b I'm sure you don't mean the above jump. > jmp 2b >4: popl %edx > popl %ecx > popl %eax > ret -- 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.