From owner-cvs-all Sat Mar 15 7:34:22 2003 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 7675E37B401; Sat, 15 Mar 2003 07:34:19 -0800 (PST) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 13DC143FB1; Sat, 15 Mar 2003 07:34:18 -0800 (PST) (envelope-from eischen@pcnet1.pcnet.com) Received: from pcnet1.pcnet.com (localhost [127.0.0.1]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h2FFYHBg027368; Sat, 15 Mar 2003 10:34:17 -0500 (EST) Received: from localhost (eischen@localhost) by pcnet1.pcnet.com (8.12.8/8.12.8/Submit) with ESMTP id h2FFYG7S027365; Sat, 15 Mar 2003 10:34:16 -0500 (EST) Date: Sat, 15 Mar 2003 10:34:16 -0500 (EST) From: Daniel Eischen To: David Xu Cc: David Schultz , cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, John Baldwin , src-committers@FreeBSD.org Subject: Re: cvs commit: src/lib/libpthread/thread thr_rwlock.c In-Reply-To: <200303151033.h2FAXjEW073717@freefall.freebsd.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, 15 Mar 2003, David Xu wrote: > > ----- Original Message ----- > From: "David Schultz" > To: "David Xu" > Cc: "John Baldwin" ; ; ; > Sent: Saturday, March 15, 2003 5:12 PM > Subject: Re: cvs commit: src/lib/libpthread/thread thr_rwlock.c > > > > Thus spake David Xu : > > > This design prevents a thread to get a reader lock recursively when > > > there is a writter blocked on a rwlock. > > > > You're right in that the standard blesses the practice of a reader > > recursing on a lock. Glancing briefly at the code, it looks like > > we presently deadlock if a writer is waiting. However, the fix is > > not so trivial. Writers *must* be given priority over readers > > within a bounded amount of time or they will be starved. Consider > > what happens when you have a neverending stream of readers. > > This can be done by keeping two lists of rwlocks the current thread owned, > both for read lock and write lock. Everytime, a thread want to lock > a rwlock, it will check one of these lists to see if it can recursively lock > it. This will make rwlock slight heavy weight. No, just keep the list of threads holding the read lock hung off the rwlock itself. I believe you only need one owner for a write lock. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message