开发者

What is difference b/w PRLock and PRRWLock

开发者 https://www.devze.com 2023-03-13 08:44 出处:网络
What is the diff开发者_C百科erence b/w PRLock and PRRWLock provided by nspr library ?I don\'t know anything about the library but the names suggest that one is a standard lock and the other is a reade

What is the diff开发者_C百科erence b/w PRLock and PRRWLock provided by nspr library ?


I don't know anything about the library but the names suggest that one is a standard lock and the other is a reader/writer lock. The first always gives exclusive access, and the second allows multiple concurrent reads but exclusive writes. For example, pthreads api has pthread_mutex_lock/pthread_mutex_unlock and pthread_rwlock_rdlock/pthread_rwlock_wrlock methods.


PRLock is a simple mutex. PRRWLock is an (unfortunately undocumented) reader-writer lock.

The only source of documentation I can find on PRRWLock is contained within prrwlock.h, and includes the methods one would expect for a reader-writer lock implementation:

  • Create and Destroy
  • Acquire Reader-lock
  • Acquire Writer-lock
  • Release the lock

An example of its usage is contained in rwlocktest.c. The rank of the lock is used for deadlock detection and is asserted in debug builds to ensure that a thread only acquires a lock of rank equal or greater to all currently held locks.

0

精彩评论

暂无评论...
验证码 换一张
取 消