why does rwlock prefer readers by default?
Rich Felker
dalias@libc.org
Wed May 7 18:51:00 GMT 2014
On Wed, May 07, 2014 at 12:33:51PM +0200, Torvald Riegel wrote:
> POSIX makes it an implementation-defined choice whether readers or
> writers are preferred. Our current implementation's default is that
> readers are to be preferred. I couldn't find the rationale for this;
> does anybody know what it was?
>
> Otherwise, if this was an arbitrary choice, what do you all think the
> default should be? Can we change it? Should we change it to preferring
> writers?
As far as I know, there is no way to prefer writers but allow
recursive locking by readers (which the standard requires be allowed)
without unbounded memory usage (to track which threads already own a
read lock). The problem is that you can't distinguish a new reader
from an existing reader performing a recurive lock and thus you have
to allow both, even if a writer is waiting. Please correct me if I'm
wrong on this.
Rich
More information about the Libc-alpha
mailing list