From owner-freebsd-arch Mon Sep 11 22: 9:17 2000 Delivered-To: freebsd-arch@freebsd.org Received: from wantadilla.lemis.com (wantadilla.lemis.com [192.109.197.80]) by hub.freebsd.org (Postfix) with ESMTP id 680EF37B423 for ; Mon, 11 Sep 2000 22:09:13 -0700 (PDT) Received: (from grog@localhost) by wantadilla.lemis.com (8.11.0/8.9.3) id e8C58td20847; Tue, 12 Sep 2000 14:38:55 +0930 (CST) (envelope-from grog) Date: Tue, 12 Sep 2000 14:38:55 +0930 From: Greg Lehey To: Chuck Paterson Cc: Jason Evans , arch@freebsd.org Subject: Re: Long-term mutex ownership (was Re: Interruptable mutex aquires.) Message-ID: <20000912143855.O88615@wantadilla.lemis.com> References: <200009120404.WAA25503@berserker.bsdi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <200009120404.WAA25503@berserker.bsdi.com>; from cp@bsdi.com on Mon, Sep 11, 2000 at 10:04:28PM -0600 Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.lemis.com/~grog X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Monday, 11 September 2000 at 22:04:28 -0600, Chuck Paterson wrote: >> I don't recall the original argument against holding mutexes for long >> periods. From an abstract point of view, there's nothing wrong with such >> practice, and in fact it makes sense for many problems. Is there an issue >> with our implementation? If so, can someone please explain it? > > If you hold a mutex across a sleep call then release of the > mutex becomes dependent upon another process. This makes it > impossible (at least from a practical point of view) to prove that > there are not deadlocks. That depends on what locks you're holding, and who else would be interested in them. > From my experience I was use to mutexs being held across sleep > (async event waits) calls. Eric Varsanyi whose background was Cray, > rather than Sun, thought we should do without them until they were > needed. That's definitely a good idea :-) > It turned out that we didn't really need them at all Well, that depends on how satisfied you are with tsleep. > so we decided to go without and not have to fight the dead lock > issues. It wasn't as if we could do with out them, it was not an > issue at all. The general consensus (which I currently don't yet share) is that we should use condition variables for things like async event waits. I'm still looking for a consistent definition of condition variables, and how they differ from "mutexes". > Mutex are for protecting data there are other mechanism for doing > the other types of synchronization. In the current system, this is correct. That doesn't mean it's necessarily the optimum. The thing I'm looking at most here is tsleep (which we have renamed msleep because of the additional mutex parameter). The real problem is wakeup: we need to search a list of processes, which is slow, and wakeup itself needs to go to the bitter end. Yes, we can use wakeup_one (which stops at the first proc with the right p_wchan), but we still need to search an average of half the chain. We have 128 hash buckets, but that's not many for a system which could have thousands of processes active. The obvious alternative is an object on which you can queue waiting processes, whether we want to call it a mutex, semaphore, condition variable or turnstile. I really need to think out some simple examples. Everything we've been doing lately looks so complicated, and though we can understand the complexity relatively well, I think it's making it difficult to gain an overview. I think our arguments are showing more our individual perspective than any real difference in viewpoint. Greg -- Finger grog@lemis.com for PGP public key See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message