This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Another LinuxThreads bug.


>     A thread may hold multiple concurrent read locks on rwlock (that is,
>     successfully call the pthread_rwlock_rdlock() function n times). If
>     so, the thread must perform matching unlocks (that is, it must call
>     the pthread_rwlock_unlock() function n times).
> 
> By making write-priority work correctly, I broke the above
> requirement, because I had no clue that recursive read locks are
> permissible.  If a thread which holds a read lock tries to acquire
> another read lock, and now one or more writers is waiting for a
> write lock, then the algorithm will lead to an obvious deadlock. The
> reader will be suspended, waiting for the writers to acquire and
> release the lock, and the writers will be suspended waiting for
> every existing read lock to be released.

That's an interesting twist!  I have no solution to offer right now,
but I believe Butenhof's book contains an implementation of RW locks
in terms of basic POSIX primitives.  That could give us some clues
(although it could be that he simply doesn't implement writer
preferencing).

- Xavier

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]