Subj : Re: NPTL rwlock is really suboptimal To : comp.programming.threads From : David Schwartz Date : Thu Jan 27 2005 10:05 am "Joseph Seigh" wrote in message news:opsk9v3ljjbs6ffg@grunion... > 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. You would only use an rwlock if you had a lot of readers and very few writers. So the implementation you should want is writer priority (no new read locks granted while a write request is pending). Another reasonably implementation (though not usually worth the extra complexity) is alternation. In this scheme, once a write lock is granted, all read locks requested after that write lock was requested are granted before another write lock is granted, read locks requested after the write lock was requested are granted immediately after the write lock is granted. DS .