> So, in summary, it's a glibc bug that has been closed as "WORKSFORME" and > will never be fixed [3]. > > In the test-pthread-rwlock test, we cannot just use > PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP, because the *purpose* of > the test is to check the behaviour of the rwlocks with the POSIX-specified > API, not with some alternative API.
What we could do, probably, is: 1) Define a module 'pthread-rwlock-writer-prefer', that guarantees to solve the first two readers-writers-problems [1] (see also [5]). 2) Optionally, implement fair rwlocks, using one of the algorithms described in [2][3][4], in a module named 'pthread-rwlock-fair'. 3) If module 'pthread-rwlock-writer-prefer' is not in use and m4/pthread_rwlock_rdlock.m4 has determined that readers are preferred and the number of CPUs is > 4, skip the test. Bruno [1] https://en.wikipedia.org/wiki/Readers%E2%80%93writers_problem [2] https://arxiv.org/abs/cs/0303005 [3] https://arxiv.org/abs/1309.4507 [4] https://rfc1149.net/blog/2011/01/07/the-third-readers-writers-problem/ [5] https://stackoverflow.com/questions/2190090/