Read/write locks do not favor writers

The i5/OS implementation of read/write locks does not favor writers. If your application has a large number of readers contending for the same lock, the writers may not be allowed to write.

The i5/OS implementation of pthread_rwlock_tryrdlock(), for example, does not completely honor the Single UNIX Specification in its treatment of reader/writer contention.

The standard states the following: "The function pthread_rwlock_tryrdlock() applies a read lock as in the pthread_rwlock_rdlock() function with the exception that the function fails if any thread holds a write lock on rwlock or there are writers blocked on rwlock."

In the i5/OS implementation, if pthread_rwlock_tryrdlock() is used on a read/write lock that has multiple readers holding the lock and multiple waiting writers blocked on the lock, the pthread_rwlock_tryrdlock() are allowed to complete successfully.


Pthread APIs | APIs by category