From owner-cvs-src Fri Mar 14 19:47:25 2003 Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4C41937B401; Fri, 14 Mar 2003 19:47:22 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E08BA43F85; Fri, 14 Mar 2003 19:47:21 -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 h2F3lLNS069889; Fri, 14 Mar 2003 19:47:21 -0800 (PST) (envelope-from davidxu@freefall.freebsd.org) Received: (from davidxu@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h2F3lLjK069888; Fri, 14 Mar 2003 19:47:21 -0800 (PST) Date: Fri, 14 Mar 2003 19:47:21 -0800 (PST) From: David Xu Message-Id: <200303150347.h2F3lLjK069888@freefall.freebsd.org> To: John Baldwin Subject: Re: cvs commit: src/lib/libpthread/thread thr_rwlock.c Cc: cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, src-committers@FreeBSD.org Sender: owner-cvs-src@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This design prevents a thread to get a reader lock recursively when there is a writter blocked on a rwlock. ----- Original Message ----- From: "John Baldwin" To: "John Baldwin" Cc: ; ; ; "David Xu" Sent: Saturday, March 15, 2003 3:31 AM Subject: RE: cvs commit: src/lib/libpthread/thread thr_rwlock.c > > On 14-Mar-2003 John Baldwin wrote: > > > > On 14-Mar-2003 David Xu wrote: > >> davidxu 2003/03/13 17:02:47 PST > >> > >> FreeBSD src repository > >> > >> Modified files: > >> lib/libpthread/thread thr_rwlock.c > >> Log: > >> Fix a bug in rwlock. When a rwlock was locked by reader threads, a > >> writter thread can block reader threads to get read lock. > > > > That's not a bug. That is a very common way of implementing reader > > writer locks. The idea is that if a writer is waiting for the lock > > you make later read requests wait for the lock so that they don't > > starve the writer. This is how Solaris rw locks work for example. > > The in-kernel sx locks don't currently work that way, but that > > may change at some point in the future. For more discussion on why > > Solaris chose this route, go find a copy of Solaris Internals. > > > > You probably should revert this and find out if this was an > > intentional design decision rather than a "bug". > > Looking at the diff a bit more: > > @@ -157,7 +157,7 @@ > return(ret); > > /* give writers priority over readers */ > - while (prwlock->blocked_writers || prwlock->state < 0) { > + while (prwlock->state < 0) { > ret = pthread_cond_wait(&prwlock->read_signal, &prwlock->lock); > > if (ret != 0) { > > The comment above the while loop seems to indicate that this was > indeed a design choice. As a result of this change the comment no > longer applies. Please revert. > > -- > > John Baldwin <>< http://www.FreeBSD.org/~jhb/ > "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-src" in the body of the message