Subj : Re: NPTL rwlock is really suboptimal To : comp.programming.threads From : Joseph Seigh Date : Thu Jan 27 2005 11:09 pm On 27 Jan 2005 18:08:22 -0800, wrote: > > 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. Yeah, I was playing with my sb100 with the orginal solaris 8. rwlocks don't hang. They don't do any better than mutexes with the work load I put on it. Sytem was wonky if I increased the threads dramatically. I should upgrade to 9 or 10 sometime if I have the time and I can find where Sun hides the system iso's and supplemental tools iso. -- Joe Seigh .