pthreads: reader/writer locks, upgrading read lock to write lock
- by ScaryAardvark
I'm using read/write locks on Linux and I've found that trying to upgrade a read locked object to a write lock deadlocks.
i.e.
// acquire the read lock in thread 1.
pthread_rwlock_rdlock( &lock );
// make a decision to upgrade the lock in threads 1.
pthread_rwlock_wrlock( &lock ); // this deadlocks as already hold read lock.
I've read…