Subj : Re: NPTL rwlock is really suboptimal To : comp.programming.threads From : roger.faulkner Date : Thu Jan 27 2005 06:08 pm Joseph Seigh wrote: > It appears to give reader preference so if you have a lot of reader thread > activity, the writer threads starve, i.e. hang indefinitely. rwlocks are > a strategy to reduce contention but if you have any kind of contention it > starves the writers. You're better off using a mutex. > > I'll have to see how Solaris rwlock handles this if I get around to porting > the atomic_ptr stuff to Solaris again. In Solaris 9 and 10, preference is given to writers. In Solaris 10, the priority of the threads is taken into account, as specified for UNIX03: The pthread_rwlock_rdlock() function applies a read lock to the read-write lock referenced by rwlock. The calling thread acquires the read lock if a writer does not hold the lock and there are no writers blocked on the lock. The calling thread does not acquire the lock if a writer holds the lock or if writers of higher or equal priority are blocked on the lock; otherwise, the calling thread acquires the lock. If the read lock is not acquired, the calling thread blocks until it can acquire the lock. Roger Faulkner roger.faulkner@sun.com .