Subject: CVS commit: [netbsd-2-0] src/sys/kern
To: None <source-changes@NetBSD.org>
From: Matthias Scheler <tron@netbsd.org>
List: source-changes
Date: 08/23/2004 05:59:27
Module Name:	src
Committed By:	tron
Date:		Mon Aug 23 05:59:27 UTC 2004

Modified Files:
	src/sys/kern [netbsd-2-0]: kern_lock.c

Log Message:
Pull up revision 1.81-1.83 via patch (requested by yamt in ticket #752):
when acquiring an exclusive lock,
ensure that no one else have the same lock.
a patch from Stephan Uphoff, FreeBSD PR/69934.
(http://www.freebsd.org/cgi/query-pr.cgi?pr=69934)
Upgrading a lock does not play well together with acquiring
an exclusive lock and can lead to two threads being
granted exclusive access.
Problematic sequence:
Thread A acquires a previous unlocked lock in shared mode.
Thread B tries to acquire the same lock in exclusive mode
and blocks.
Thread A upgrades its lock - waking up thread B.
Thread B wakes up and also acquires the same lock as it only checks
if the lock is not shared or if someone wants to upgrade the lock
and not if someone already upgraded the lock to an exclusive lock.
- revert a part of the previous which breaks LK_SPIN locks.
  (reported by Nicolas Joly on current-users@)
- propagate the previous to spinlock_acquire_count.
add missing wakeups in the cases of lock failure.
from Stephan Uphoff, FreeBSD PR/69964.


To generate a diff of this commit:
cvs rdiff -r1.75 -r1.75.2.1 src/sys/kern/kern_lock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.