Joe Seigh
8/7/2004 3:34:00 PM
Joe Seigh wrote:
>
> SenderX wrote:
> >
> > I am wondering about the performance of a writer spin-waiting for a bunch of
> > readers... Should the writer block after a couple of spins?
> >
> > I need to bench this against my cas version that will block threads after a
> > couple of spins...
>
> Well, it's a spin lock. Not really meant to be the other kind. If you add in
> blocking, you'd need a blocking mechanism that would handle the service order
> correctly.
>
> You'd probably need the futex equivalent of an eventticket mechanism. But as
> soon as you but in blocking the adaptive locks which allow queue jumping
> will perform better under some conditions.
>
Actually, I'm not sure what queue jumping would by you in a read-write lock.
The fact that you are using a read-write lock means that contention is an
issue, otherwise you'd be using a mutex which has less overhead than rwlocks in most
implementations. So going with a FIFO service order may be an optimal strategy.
Joe Seigh