From owner-cvs-all@FreeBSD.ORG Wed Apr 14 08:42:59 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4AE3416A4CE for ; Wed, 14 Apr 2004 08:42:59 -0700 (PDT) Received: from mail2.speakeasy.net (mail2.speakeasy.net [216.254.0.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0900443D39 for ; Wed, 14 Apr 2004 08:42:59 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: (qmail 1302 invoked from network); 14 Apr 2004 15:42:56 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 14 Apr 2004 15:42:56 -0000 Received: from 10.50.40.205 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.10/8.12.10) with ESMTP id i3EFfYe3001084; Wed, 14 Apr 2004 11:42:36 -0400 (EDT) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: Bill Paul Date: Wed, 14 Apr 2004 11:05:43 -0400 User-Agent: KMail/1.6 References: <200404140748.i3E7m4HV067995@repoman.freebsd.org> In-Reply-To: <200404140748.i3E7m4HV067995@repoman.freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200404141105.43663.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx cc: cvs-src@FreeBSD.org cc: src-committers@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/compat/ndis hal_var.h kern_ndis.c ndis_var.h ntoskrnl_var.h pe_var.h subr_hal.c subr_ndis.c subr_ntoskrnl.c src/sys/dev/if_ndis if_ndis.c if_ndisvar.h X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Apr 2004 15:42:59 -0000 On Wednesday 14 April 2004 03:48 am, Bill Paul wrote: > wpaul 2004/04/14 00:48:03 PDT > > FreeBSD src repository > > Modified files: > sys/compat/ndis hal_var.h kern_ndis.c ndis_var.h > ntoskrnl_var.h pe_var.h subr_hal.c > subr_ndis.c subr_ntoskrnl.c > sys/dev/if_ndis if_ndis.c if_ndisvar.h > Log: > Continue my efforts to imitate Windows as closely as possible by > attempting to duplicate Windows spinlocks. Windows spinlocks differ > from FreeBSD spinlocks in the way they block preemption. FreeBSD > spinlocks use critical_enter(), which masks off _all_ interrupts. > This prevents any other threads from being scheduled, but it also > prevents ISRs from running. In Windows, preemption is achieved by > raising the processor IRQL to DISPATCH_LEVEL, which prevents other > threads from preempting you, but does _not_ prevent device ISRs > from running. (This is essentially what Solaris calls dispatcher > locks.) The Windows spinlock itself (kspin_lock) is just an integer > value which is atomically set when you acquire the lock and atomically > cleared when you release it. > > FreeBSD doesn't have IRQ levels, so we have to cheat a little by > using thread priorities: normal thread priority is PASSIVE_LEVEL, > lowest interrupt thread priority is DISPATCH_LEVEL, highest thread > priority is DEVICE_LEVEL (PI_REALTIME) and critical_enter() is > HIGH_LEVEL. In practice, only PASSIVE_LEVEL and DISPATCH_LEVEL > matter to us. The immediate benefit of all this is that I no > longer have to rely on a mutex pool. > > Now, I'm sure many people will be seized by the urge to criticize > me for doing an end run around our own spinlock implementation, but > it makes more sense to do it this way. Well, it does to me anyway. If you don't use atomic ops with memory barriers somewhere (like the mutex implementation does) then NDIS won't work on SMP. Really, IRQL is basically spl()s, and we don't use an spl-like model anymore. Just using mutexes for locking should give you all the protection you need. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org