[Prev] [Contents] [Next]

Read/Write locks do not favor writers (writer starvation is possible)

The OS/400 implementation of read/write locks does not favor writers. Its possible that if your application has a large number of readers, each contending for the lock, that the writers will be starved.

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

The standard says: "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 OS/400 implementation, if pthread_rwlock_tryrdlock() function 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() will be allowed to complete successfully.



[Prev] [Contents] [Next]
Copyright © 1998, IBM Corporation. All rights reserved.
Comments? Contact
rchthrds@us.ibm.com