summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-03-28 02:40:47 +0000
committerjhb <jhb@FreeBSD.org>2001-03-28 02:40:47 +0000
commit4572ff9c78f9e673b960845742b5efce77d07348 (patch)
tree118249692a5e69c7cb4a44540b33e1ec40b0f35d /sys/kern/kern_mutex.c
parentfdbf402b8548ef52a4bc5f1d4f27038556bfbf93 (diff)
downloadFreeBSD-src-4572ff9c78f9e673b960845742b5efce77d07348.zip
FreeBSD-src-4572ff9c78f9e673b960845742b5efce77d07348.tar.gz
- Switch from using save/disable/restore_intr to using critical_enter/exit
and change the u_int mtx_saveintr member of struct mtx to a critical_t mtx_savecrit. - On the alpha we no longer need a custom _get_spin_lock() macro to avoid an extra PAL call, so remove it. - Partially fix using mutexes with WITNESS in modules. Change all the _mtx_{un,}lock_{spin,}_flags() macros to accept explicit file and line parameters and rename them to use a prefix of two underscores. Inside of kern_mutex.c, generate wrapper functions for _mtx_{un,}lock_{spin,}_flags() (only using a prefix of one underscore) that are called from modules. The macros mtx_{un,}lock_{spin,}_flags() are mapped to the __mtx_* macros inside of the kernel to inline the usual case of mutex operations and map to the internal _mtx_* functions in the module case so that modules will use WITNESS and KTR logging if the kernel is compiled with support for it.
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 6540b56..ee285af 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -285,6 +285,38 @@ propagate_priority(struct proc *p)
}
/*
+ * Function versions of the inlined __mtx_* macros. These are used by
+ * modules and can also be called from assembly language if needed.
+ */
+void
+_mtx_lock_flags(struct mtx *m, int opts, const char *file, int line)
+{
+
+ __mtx_lock_flags(m, opts, file, line);
+}
+
+void
+_mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line)
+{
+
+ __mtx_unlock_flags(m, opts, file, line);
+}
+
+void
+_mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line)
+{
+
+ __mtx_lock_spin_flags(m, opts, file, line);
+}
+
+void
+_mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line)
+{
+
+ __mtx_unlock_spin_flags(m, opts, file, line);
+}
+
+/*
* The important part of mtx_trylock{,_flags}()
* Tries to acquire lock `m.' We do NOT handle recursion here; we assume that
* if we're called, it's because we know we don't already own this lock.
@@ -461,7 +493,7 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
* is handled inline.
*/
void
-_mtx_lock_spin(struct mtx *m, int opts, u_int mtx_intr, const char *file,
+_mtx_lock_spin(struct mtx *m, int opts, critical_t mtx_crit, const char *file,
int line)
{
int i = 0;
@@ -488,7 +520,7 @@ _mtx_lock_spin(struct mtx *m, int opts, u_int mtx_intr, const char *file,
}
}
- m->mtx_saveintr = mtx_intr;
+ m->mtx_savecrit = mtx_crit;
if ((opts & MTX_QUIET) == 0)
CTR1(KTR_LOCK, "_mtx_lock_spin: %p spin done", m);
OpenPOWER on IntegriCloud