From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 13 19:21:40 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4CEB916A420 for ; Fri, 13 Jan 2006 19:21:40 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.FreeBSD.org (Postfix) with ESMTP id 94ED543D48 for ; Fri, 13 Jan 2006 19:21:39 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.5b3) with ESMTP id 5998422 for multiple; Fri, 13 Jan 2006 14:20:07 -0500 Received: from localhost (john@localhost [127.0.0.1]) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k0DJLaKF096034; Fri, 13 Jan 2006 14:21:36 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Fri, 13 Jan 2006 14:22:14 -0500 User-Agent: KMail/1.8.2 References: <1fa17f810601122232l25551bc5n4e4a01ff6b7921e@mail.gmail.com> <1fa17f810601130220h521590banff7d775a8bd4eaa6@mail.gmail.com> In-Reply-To: <1fa17f810601130220h521590banff7d775a8bd4eaa6@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200601131422.15208.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1240/Fri Jan 13 11:57:12 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=ALL_TRUSTED autolearn=failed version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx X-Server: High Performance Mail Server - http://surgemail.com r=1653887525 Cc: prime , "Kamal R. Prasad" Subject: Re: How priority propagation works on read/write lock? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jan 2006 19:21:40 -0000 On Friday 13 January 2006 05:20 am, prime wrote: > On 1/13/06, Kamal R. Prasad wrote: > > Priority need not be propagated to readers as they will not block other > > readers. > > Most likely, you only need to propagate to the writer to avoid priority > > inversron. > > > > regards > > -kamal > > > > On 1/13/06, prime wrote: > > > Hi hackers, > > > I have a question about how priority propagation works on > > > read/write lock.On locks that have only one owner at a determinate > > > moment,we can simply propagate the priority to the owner of lock,but > > > read/write lock may have many owners at some time,so how can we know > > > who are the owners? > > > I browse the OpenSolaris' read/write lock implementation,and find > > > that, it simply treats the owner of the lock as NULL when readers own > > > the read/write lock.In this way,we can not propagate our priority to > > > all threads that block us. > > > > > > Thanks very much. > > > -- > > > Three passions, simple but overwhelmingly strong, have governed my > > > life: > > > > > > the longing for love, the search for knowledge, and unbearable pity for > > > the suffering of mankind. > > > ---------Bertrand Russell > > > _______________________________________________ > > > freebsd-hackers@freebsd.org mailing list > > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > > To unsubscribe, send any mail to > > > "freebsd-hackers-unsubscribe@freebsd.org " > > Thanks your reply. > But readers may block writers, aren't they? > For example, there are three threads,A,B and C, and a read/write lock > rwlock1 ,and a mutex mtx1. > 1.A lock mtx1, > 2.B get the read lock of rwlock1 and then want > to get mtx1,but mtx1 is locked by A,so B has to > wait on mtx1. > 3.C want to get the write lock of rwlock1 and it > has to wait,because rwlock1 is read locked by B. > Now if C's priority < A's priority(in numerical), then we get priority > inversion. > > How can avoid this priority inversion? > Thanks. I think you just kind of punt and do a best effort. Trying to manage a list of current read lock holders would be a bit PITA. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org