From owner-cvs-src@FreeBSD.ORG Mon Jan 19 06:52:08 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1E69316A4CE; Mon, 19 Jan 2004 06:52:08 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAE8543D6D; Mon, 19 Jan 2004 06:51:45 -0800 (PST) (envelope-from mtm@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i0JEpj0B039696; Mon, 19 Jan 2004 06:51:45 -0800 (PST) (envelope-from mtm@repoman.freebsd.org) Received: (from mtm@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i0JEpjT6039692; Mon, 19 Jan 2004 06:51:45 -0800 (PST) (envelope-from mtm) Message-Id: <200401191451.i0JEpjT6039692@repoman.freebsd.org> From: Mike Makonnen Date: Mon, 19 Jan 2004 06:51:45 -0800 (PST) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/lib/libthr/thread thr_exit.c thr_private.h thr_rwlock.c X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2004 14:52:08 -0000 mtm 2004/01/19 06:51:45 PST FreeBSD src repository Modified files: lib/libthr/thread thr_exit.c thr_private.h thr_rwlock.c Log: 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 ] Revision Changes Path 1.11 +6 -0 src/lib/libthr/thread/thr_exit.c 1.29 +16 -0 src/lib/libthr/thread/thr_private.h 1.4 +133 -8 src/lib/libthr/thread/thr_rwlock.c