From owner-cvs-all Sat Mar 15 2:33:49 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 3BB8A37B401; Sat, 15 Mar 2003 02:33:46 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DAD5943FAF; Sat, 15 Mar 2003 02:33:45 -0800 (PST) (envelope-from davidxu@FreeBSD.org) Received: from freefall.freebsd.org (davidxu@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h2FAXjNS073718; Sat, 15 Mar 2003 02:33:45 -0800 (PST) (envelope-from davidxu@freefall.freebsd.org) Received: (from davidxu@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h2FAXjEW073717; Sat, 15 Mar 2003 02:33:45 -0800 (PST) Date: Sat, 15 Mar 2003 02:33:45 -0800 (PST) From: David Xu Message-Id: <200303151033.h2FAXjEW073717@freefall.freebsd.org> To: David Schultz Subject: Re: cvs commit: src/lib/libpthread/thread thr_rwlock.c Cc: cvs-all@FreeBSD.ORG, cvs-src@FreeBSD.ORG, John Baldwin , src-committers@FreeBSD.ORG 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 ----- 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. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message