lkml.org 
[lkml]   [1999]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch] shm bug introduced with pagecache in 2.3.11


On Sat, 20 Nov 1999, Manfred Spraul wrote:
>
> I never figured out how to upgrade a reader to a writer:

You can't, without extra rules.

What you CAN do is have a "halfway writer", which allows other readers to
come in, but doesn't allow other writers or "halfway writers". Then, when
you upgrade to a real writer, you basically wait for all the readers to go
away.

Such a halfway writer allows you to get the "halfwrite" lock early,
without impacting any readers - so it almost acts like a read lock.

But upgrading froma pure read-lock is impossible in general, simply
because of the obvious deadlock with two readers that both want to
upgrade.

Linus

[ With the current i386 rwlock implementation, a "halfway writer" is
essentially one that has atomically set the sign bit in the
reader/writer word, but hasn't bothered to wait for all readers to go
away. That is enough to make sure no further writers or halfway writers
will enter the critical region, and we can just wait for the readers to
exit. Basically you have

/* Get the "halfway lock" */
upgrader_lock(rw)
lock btsl $31,%0
jc fixup

/* Upgrade it to a _real_ write lock by waiting for readers to go away */
upgrade(rw)
repeat:
testl $0x7fffffff,%0
jne repeat

and the above is untested but should work - something similar should
work for the rw-semaphore case, but for the mm semaphore this is
probably not useful because of the still fairly exclusive nature of the
upgrader.. ]


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.060 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site