Re: POSIX rwlocks vs. glib2 rwlocks



Hi Kaz,

> Read-write locks are functional, and also provide several flavors of
> lock: writer preference, reader preference, and writer preference
> without recursive read locking.
> 
> Writer precedence is the default type, and supports recursive read
> locking as well, which is tricky (what if a thread which owns a read
> lock wants to get another read on the same lock, but writers have
> queued up in the meanwhile? POSIX requires that the reader is granted
> the additional lock, and the glibc2 implementation makes it work
> correctly).

This indeed is tricky. Actually I haven't thought of that yet. So actually our
documentation is wrong in saying:

GStaticRWLock in general is not recursive, but as there may be unlimited
concurrent locks for reading, it effectively is for recursive for reading, but
for reading only. Locking for writing after locking for reading will deadlock,
the same holds true for the opposite order.

That has to be fixed. On the other hand a fully recursive rwlock might be nice
to have. I suppose the work you have to invest to enable read lock recursion
is enough to also enbable full (mixed read/write) recursion.

I'll have a look.

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]