Re: Are PRRWLock read locks reentrant?

Wan-Teh Chang <[email protected]> Tue, 18 Nov 2008 16:49:52 -0800
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
On Tue, Nov 18, 2008 at 1:39 PM, Nathan Kinder <[email protected]> wrote:
> I know that a PRLock is not reentrant, but is getting a read lock on a
> PRRWLock using PR_RWLock_Rlock() reentrant?

I checked the implementation.  The answer is Yes, it is reentrant.
This is reasonable because a reader-writer lock allows multiple
readers, including a reader acquiring it multiple times.  See also
the pthread_rwlock_rdlock man page at
http://opengroup.org/onlinepubs/007908799/xsh/pthread_rwlock_rdlock.html
which says:

  A thread may hold multiple concurrent read locks on rwlock (that is,
  successfully call the pthread_rwlock_rdlock() function n times). If so,
  the thread must perform matching unlocks (that is, it must call the
  pthread_rwlock_unlock() function n times).

Wan-Teh