From owner-freebsd-arch Sat Sep 23 20: 4:16 2000 Delivered-To: freebsd-arch@freebsd.org Received: from berserker.bsdi.com (berserker.twistedbit.com [199.79.183.1]) by hub.freebsd.org (Postfix) with ESMTP id 948CC37B424; Sat, 23 Sep 2000 20:04:13 -0700 (PDT) Received: from berserker.bsdi.com (cp@LOCALHOST [127.0.0.1]) by berserker.bsdi.com (8.9.3/8.9.3) with ESMTP id VAA20719; Sat, 23 Sep 2000 21:02:49 -0600 (MDT) Message-Id: <200009240302.VAA20719@berserker.bsdi.com> To: Archie Cobbs Cc: Brian Somers , Joerg Micheel , Greg Lehey , Matthew Jacob , Frank Mayhar , John Baldwin , Mark Murray , FreeBSD-arch@freebsd.org Subject: Re: Mutexes and semaphores (was: cvs commit: src/sys/conf files src/sys/sys random.h src/sys/dev/randomdev hash.c hash.h harvest.c randomdev.c yarrow.c yarro) In-reply-to: Your message of "Sat, 23 Sep 2000 12:42:47 PDT." <200009231942.MAA06755@bubba.whistle.com> From: Chuck Paterson Date: Sat, 23 Sep 2000 21:02:49 -0600 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG }Once you have the spin lock primitive, you can easily build }semaphores, sleep queues, etc. A semaphore is just a counter plus }a sleep queue -- all protected by the spin lock. } }A MUTEX is just a sepaphore whose initial count is 1. } }?? In general this might be true, but in specific it isn't. The sleep version of mutexs have no spin lock. Spin locks are more expensive than the mutices currently in FreeBSD and BSD/OS. In order to acquire a spin locks interrupts must be blocked, which isn't the case for mutices which are not contested. Chuck To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message