From owner-freebsd-hackers@FreeBSD.ORG Sat Jan 14 19:09:07 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 B2B5416A41F for ; Sat, 14 Jan 2006 19:09:07 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1338E43D48 for ; Sat, 14 Jan 2006 19:09:06 +0000 (GMT) (envelope-from guomingyan@gmail.com) Received: by xproxy.gmail.com with SMTP id t12so662662wxc for ; Sat, 14 Jan 2006 11:09:06 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=rNDveHzSqE7/5GmvCcGueTNwAcVrYvbnLq5jcrWDOf8B2t8UnVuP1B25HiiykljCS2nTEV8aRNQPTOUyetX/ZF81Y6NOsG7fRjicE9daoQvixNaSftQLa4x+UwDhCiPu2X2U4ZJIGt+zGFhl3PMHSuG5gMibkkFEyUzXkom6jzY= Received: by 10.70.14.6 with SMTP id 6mr4638022wxn; Sat, 14 Jan 2006 11:09:04 -0800 (PST) Received: by 10.70.39.18 with HTTP; Sat, 14 Jan 2006 11:09:04 -0800 (PST) Message-ID: <1fa17f810601141109u3e3a0586ud3b3cc86ebc6e80@mail.gmail.com> Date: Sun, 15 Jan 2006 03:09:04 +0800 From: prime To: Tiffany Snyder In-Reply-To: MIME-Version: 1.0 References: <1fa17f810601122232l25551bc5n4e4a01ff6b7921e@mail.gmail.com> <1fa17f810601130220h521590banff7d775a8bd4eaa6@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org 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: Sat, 14 Jan 2006 19:09:07 -0000 On 1/15/06, Tiffany Snyder wrote: > > Does FreeBSD support rwlocks? > > On 1/13/06, 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 < guomingyan@gmail.com> 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,bu= t > > > > read/write lock may have many owners at some time,so how can we kno= w > > > > 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 t= o > > > > 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. > > > > -- > > 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" > > > > FreeBSD supports sx now,see sx(9).sx has the same semanteme as rwlock. -- 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