How priority propagation works on read/write lock?
John Baldwin
jhb at freebsd.org
Fri Jan 13 11:21:40 PST 2006
On Friday 13 January 2006 05:20 am, prime wrote:
> On 1/13/06, Kamal R. Prasad <kamalp at acm.org> 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 at 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,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 at freebsd.org mailing list
> > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > > To unsubscribe, send any mail to
> > > "freebsd-hackers-unsubscribe at 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 <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the freebsd-hackers
mailing list