From: Allen Pulsifer (pulsifer3_at_[hidden])
Date: 2007-08-03 11:47:50
Thanks. Glad I asked; I think I'm straight now.
This looks like a standard rwlock implementation: if there is a writer
waiting, then all new readers block. Correct?
One comment: I noticed shared_count is only 10 bits. That's probably large
enough for most applications, but at the same time, small enough that the
counter could rollover in practice, with catastrophic results.
I would suggest:
- byte the bullet and make shared_count 26 bits;
- test for shared_count reaching its maximum, and then either return busy,
or make additional readers block until 100 or so slots become free (in this
situation, there's no reason to wake waiters every time a reader finishes,
since the machine is probably already overloaded).
Thanks for the implementation,