diff options
author | jhb <jhb@FreeBSD.org> | 2001-06-25 18:29:32 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-06-25 18:29:32 +0000 |
commit | 2660b97507e58be771bd932c06af432819a16aea (patch) | |
tree | e6cd45594172cba6bb847805c2960bf291581107 /sys/kern/kern_mutex.c | |
parent | fdfd5d01a716f63bcaf43182ffb35b88a505f1b7 (diff) | |
download | FreeBSD-src-2660b97507e58be771bd932c06af432819a16aea.zip FreeBSD-src-2660b97507e58be771bd932c06af432819a16aea.tar.gz |
Count the context switch when blocking on a mutex as a voluntary context
switch. Count the context switch when preempting the current thread to let
a higher priority thread blocked on a mutex we just released run as an
involuntary context switch.
Reported by: bde
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r-- | sys/kern/kern_mutex.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 0007a8b..f2740f6 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -64,6 +64,7 @@ #include <sys/malloc.h> #include <sys/mutex.h> #include <sys/proc.h> +#include <sys/resourcevar.h> #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/vmmeter.h> @@ -399,6 +400,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_lock_sleep: p %p blocked on [%p] %s", p, m, m->mtx_object.lo_name); + p->p_stats->p_ru.ru_nvcsw++; mi_switch(); if (LOCK_LOG_TEST(&m->mtx_object, opts)) @@ -536,6 +538,7 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line) "_mtx_unlock_sleep: %p switching out lock=%p", m, (void *)m->mtx_lock); + p->p_stats->p_ru.ru_nivcsw++; mi_switch(); if (LOCK_LOG_TEST(&m->mtx_object, opts)) CTR2(KTR_LOCK, "_mtx_unlock_sleep: %p resuming lock=%p", |