From owner-cvs-src@FreeBSD.ORG Wed Apr 14 15:04:53 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 618) id 7806316A4CF; Wed, 14 Apr 2004 15:04:53 -0700 (PDT) In-Reply-To: <200404141105.43663.jhb@FreeBSD.org> from John Baldwin at "Apr 14, 2004 11:05:43 am" To: jhb@FreeBSD.org (John Baldwin) Date: Wed, 14 Apr 2004 15:04:53 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20040414220453.7806316A4CF@hub.freebsd.org> From: wpaul@FreeBSD.ORG (Bill Paul) 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_ntoskrn X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Apr 2004 22:04:53 -0000 > > 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. Protection is all well and good, but I need to provide the right semantics as well. I need to fool the drivers into thinking they can depend on the usual Windows behavior, and make it easy to use the Windows data types, and it's a pain in the butt to do that with regular mutexes. And besides, I wanna. Now, from subr_ntoskrnl.c: __stdcall void ntoskrnl_lock_dpc(/*lock*/ void) { kspin_lock *lock; __asm__ __volatile__ ("" : "=c" (lock)); while (atomic_cmpset_int((volatile u_int *)lock, 0, 1) == 0) /* do nothing */; return; } __stdcall void ntoskrnl_unlock_dpc(/*lock*/ void) { kspin_lock *lock; __asm__ __volatile__ ("" : "=c" (lock)); atomic_cmpset_int((volatile u_int *)lock, 1, 0); return; } These two routines do the actual work of acquiring and releasing the lock (they map to KefAcquireSpinLockAtDpcLevel() and KefReleaseSpinLockFromDpcLevel). Are you saying the former routine should use atomic_cmpset_acq_int() and the latter atomic_cmpset_rel_int()? -Bill -- ============================================================================= -Bill Paul (510) 749-2329 | Senior Engineer, Master of Unix-Fu wpaul@windriver.com | Wind River Systems ============================================================================= you're just BEGGING to face the moose =============================================================================