Walter is right about transitive readonly - here's the alternative
Janice Caron
caron800 at googlemail.com
Thu Sep 13 14:10:13 PDT 2007
On 9/13/07, Sean Kelly <sean at f4.ca> wrote:
> > Upgrading just isn't possible in any case - not even in /theory/, let
> > alone in a given implementation.
>
> I'm sure it could be done
It certainly can't be done atomically...
Threads 1 and 2 both successfully obtain a read lock.
Thread 1 attempts to upgrade to a write lock. Since thread 2 has a
read lock, it waits.
Thread 2 attempts to upgrade to a write lock. Since thread 1 has a
read lock, it waits.
Deadlock.
> (in fact, POSIX has this feature)
I wonder how. If it's implemented as release the read lock followed by
obtain a write lock, then the caller must beware that another thread
may have written /during/ the upgrade.
More information about the Digitalmars-d
mailing list