]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Implement reference counting of read-write locks. This uses
authormtm <mtm@FreeBSD.org>
Mon, 19 Jan 2004 14:51:45 +0000 (14:51 +0000)
committermtm <mtm@FreeBSD.org>
Mon, 19 Jan 2004 14:51:45 +0000 (14:51 +0000)
commit2d3f49ebd38d6441b693d51adcf071088817ddf5
tree8ea09bd49e1effae3ff537f35c5766a1cdc3bf69
parentfc6eb88ff293065b8973e0a33349d6ee1547181c
Implement reference counting of read-write locks. This uses
a list in the thread structure to keep track of the locks and
how many times they have been locked. This list is checked
on every lock and unlock. The traversal through the list is
O(n). Most applications don't hold so many locks at once that
this will become a problem. However, if it does become a problem
it might be a good idea to review this once libthr is
off probation and in the optimization cycle.
This fixes:
o deadlock when a thread tries to recursively acquire a
  read lock when a writer is waiting on the lock.
o a thread could previously successfully unlock a lock it did not own
o deadlock when a thread tries to acquire a write lock on
  a lock it already owns for reading or writing [ this is admittedly
  not required by POSIX, but is nice to have ]
lib/libthr/thread/thr_exit.c
lib/libthr/thread/thr_private.h
lib/libthr/thread/thr_rwlock.c