From owner-cvs-src Sun Mar 16 8: 9: 7 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 7077937B404; Sun, 16 Mar 2003 08:09:04 -0800 (PST) Received: from mta08bw.bigpond.com (mta08bw.bigpond.com [144.135.24.137]) by mx1.FreeBSD.org (Postfix) with ESMTP id 40BCA43F85; Sun, 16 Mar 2003 08:09:01 -0800 (PST) (envelope-from darrenr@reed.wattle.id.au) Received: from CPE-61-9-164-106.vic.bigpond.net.au ([144.135.24.78]) by mta08bw.bigpond.com (Netscape Messaging Server 4.15 mta08bw Jul 16 2002 22:47:55) with SMTP id HBUNIY00.9GM; Mon, 17 Mar 2003 02:08:58 +1000 Received: from CPE-203-51-130-110.vic.bigpond.net.au ([203.51.130.110]) by bwmam04bpa.bigpond.com(MailRouter V3.2g 35/1210690); 17 Mar 2003 02:09:23 Received: (from root@localhost) by CPE-61-9-164-106.vic.bigpond.net.au (8.11.0/8.11.0) id h2GG8vP07187; Mon, 17 Mar 2003 03:08:57 +1100 From: Darren Reed Message-Id: <200303161608.DAA02164@avalon.reed.wattle.id.au> Subject: Re: cvs commit: src/lib/libpthread/thread thr_rwlock.c In-Reply-To: <200303150347.h2F3lLjK069888@freefall.freebsd.org> To: David Xu Date: Mon, 17 Mar 2003 03:08:40 +1100 Cc: John Baldwin , cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, src-committers@FreeBSD.org X-Mailer: ELM [version 2.4ME+ PL99d (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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 So what you're saying is this design prevents bad code being written. And the problem is ? In some email I received from David Xu, sie wrote: > 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