Making pthread_rwlock_wrlock recursive
I have a problem regarding the behaviour of the pthread function pthread_rwlock_wrlock . The specification linked above states that when one thread has locked the lock for writing and the same thread locks it again, it results in undefined behaviour (I could actually observe this in that on x86 Linux calling this function is a noop and on PowerPC Linux it stalls the thread). The behaviour I need would be a read write lock that has the following characteristics: read-locking by a thread succeeds if: the lock is not held by any thread the lock is only read-locked by zero or more threads