Subject: CVS commit: src/sys/kern
To: None <source-changes@NetBSD.org>
From: YAMAMOTO Takashi <yamt@netbsd.org>
List: source-changes
Date: 08/03/2004 12:08:51
Module Name:	src
Committed By:	yamt
Date:		Tue Aug  3 12:08:51 UTC 2004

Modified Files:
	src/sys/kern: kern_lock.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -r1.80 -r1.81 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.