
"Anthony Williams" <anthony_w.geo@yahoo.com> wrote in message news:zmbl66cr.fsf@yahoo.com...
"Chris Thomasson" <cristom@comcast.net> writes:
"Anthony Williams" <anthony_w.geo@yahoo.com> wrote in message news:d58h7nlv.fsf@yahoo.com...
The way I see it, the ideal is that a waiting writer will block any fresh readers until all the current readers have gone away, but once that happens, and the lock is released, the waiting writer and the waiting readers will compete equally.
[...]
Again, if your rw-mutex is getting hit with enough writes to even begin to start to starve the readers, then the user of the rw-mutex is using it improperly... IMHO of course...
I agree that preventing writers starving should be sufficient in most cases. I just happen to think that it's less than ideal.
I was imagining a system with several hundred readers, and a couple of writers. If the writers take sufficiently long, you might find that you have one waiting on the other. The readers then get starved if you give writers priority, just as the writers get starved if you give readers priority.
Well, if you are using hundreds of reader threads, then basically any rw-mutex is less than ideal in most cases, IMO: http://groups.google.com/group/comp.programming.threads/msg/fdc665e616176dce Humm...