read/write locks

A new implementation of read/write locks for POSIX systems, hopefully solving the problem that POSIX pthreads implementations generally disallow any thread but the original locker from unlocking a read/write lock.

Reference #1277.

Not ready to merge.