- Add/correct comments.
- Print correct function name when an assertion triggers.
This commit is contained in:
parent
b173114f5c
commit
6bcf70b518
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_mutex.c,v 1.2 2007/02/09 21:55:30 ad Exp $ */
|
||||
/* $NetBSD: kern_mutex.c,v 1.3 2007/02/10 21:07:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -49,7 +49,7 @@
|
||||
#define __MUTEX_PRIVATE
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.2 2007/02/09 21:55:30 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.3 2007/02/10 21:07:52 ad Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
@ -261,15 +261,16 @@ mutex_dump(volatile void *cookie)
|
||||
/*
|
||||
* mutex_abort:
|
||||
*
|
||||
* Dump information about an error and panic the system.
|
||||
* Dump information about an error and panic the system. This
|
||||
* generates a lot of machine code in the DIAGNOSTIC case, so
|
||||
* we ask the compiler to not inline it.
|
||||
*/
|
||||
__attribute ((noinline)) __attribute ((noreturn)) void
|
||||
mutex_abort(kmutex_t *mtx, const char *func, const char *msg)
|
||||
{
|
||||
|
||||
LOCKDEBUG_ABORT(MUTEX_GETID(mtx), mtx, (MUTEX_SPIN_P(mtx) ?
|
||||
&mutex_spin_lockops : &mutex_adaptive_lockops),
|
||||
__FUNCTION__, msg);
|
||||
&mutex_spin_lockops : &mutex_adaptive_lockops), func, msg);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@ -340,6 +341,9 @@ mutex_destroy(kmutex_t *mtx)
|
||||
* Note that we can't use the mutex owner field as an LWP pointer. We
|
||||
* don't have full control over the timing of our execution, and so the
|
||||
* pointer could be completely invalid by the time we dereference it.
|
||||
*
|
||||
* XXX This should be optimised further to reduce potential cache line
|
||||
* ping-ponging and skewing of the spin time while busy waiting.
|
||||
*/
|
||||
#ifdef MULTIPROCESSOR
|
||||
int
|
||||
@ -354,14 +358,14 @@ mutex_onproc(uintptr_t owner, struct cpu_info **cip)
|
||||
l = (struct lwp *)MUTEX_OWNER(owner);
|
||||
|
||||
if ((ci = *cip) != NULL && ci->ci_curlwp == l) {
|
||||
mb_read(); /* XXXSMP Necessary? */
|
||||
mb_read(); /* XXXSMP Very expensive, necessary? */
|
||||
return ci->ci_biglock_wanted != l;
|
||||
}
|
||||
|
||||
for (CPU_INFO_FOREACH(cii, ci)) {
|
||||
if (ci->ci_curlwp == l) {
|
||||
*cip = ci;
|
||||
mb_read(); /* XXXSMP Necessary? */
|
||||
mb_read(); /* XXXSMP Very expensive, necessary? */
|
||||
return ci->ci_biglock_wanted != l;
|
||||
}
|
||||
}
|
||||
@ -699,7 +703,8 @@ mutex_vector_exit(kmutex_t *mtx)
|
||||
/*
|
||||
* mutex_owned:
|
||||
*
|
||||
* Return true if the current thread holds the mutex.
|
||||
* Return true if the current LWP (adaptive) or CPU (spin)
|
||||
* holds the mutex.
|
||||
*/
|
||||
int
|
||||
mutex_owned(kmutex_t *mtx)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_rwlock.c,v 1.2 2007/02/09 21:55:31 ad Exp $ */
|
||||
/* $NetBSD: kern_rwlock.c,v 1.3 2007/02/10 21:07:52 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -47,7 +47,7 @@
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.2 2007/02/09 21:55:31 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.3 2007/02/10 21:07:52 ad Exp $");
|
||||
|
||||
#define __RWLOCK_PRIVATE
|
||||
|
||||
@ -384,6 +384,7 @@ rw_vector_exit(krwlock_t *rw)
|
||||
*/
|
||||
ts = turnstile_lookup(rw);
|
||||
RW_DASSERT(rw, ts != NULL);
|
||||
RW_DASSERT(rw, (rw->rw_owner & RW_HAS_WAITERS) != 0);
|
||||
|
||||
owner = rw->rw_owner;
|
||||
wcnt = TS_WAITERS(ts, TS_WRITER_Q);
|
||||
@ -398,7 +399,6 @@ rw_vector_exit(krwlock_t *rw)
|
||||
*/
|
||||
if (rcnt == 0 || (decr == RW_READ_INCR && wcnt != 0)) {
|
||||
RW_DASSERT(rw, wcnt != 0);
|
||||
RW_DASSERT(rw, (rw->rw_owner & RW_HAS_WAITERS) != 0);
|
||||
RW_DASSERT(rw, (rw->rw_owner & RW_WRITE_WANTED) != 0);
|
||||
|
||||
/*
|
||||
@ -424,13 +424,11 @@ rw_vector_exit(krwlock_t *rw)
|
||||
turnstile_wakeup(ts, TS_WRITER_Q, wcnt, l);
|
||||
} else {
|
||||
RW_DASSERT(rw, rcnt != 0);
|
||||
RW_DASSERT(rw, (rw->rw_owner & RW_HAS_WAITERS) != 0);
|
||||
|
||||
/*
|
||||
* Give the lock to all blocked readers. We may
|
||||
* retain one read hold if downgrading. If there
|
||||
* is a writer waiting, new readers will be blocked
|
||||
* out.
|
||||
* Give the lock to all blocked readers. If there
|
||||
* is a writer waiting, new readers that arrive
|
||||
* after the release will be blocked out.
|
||||
*/
|
||||
new = rcnt << RW_READ_COUNT_SHIFT;
|
||||
if (wcnt != 0)
|
||||
|
Loading…
Reference in New Issue
Block a user