summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-03-04 21:32:25 +0000
committerjhb <jhb@FreeBSD.org>2003-03-04 21:32:25 +0000
commit1ec02223897c43798625b70595c5897706ddaf52 (patch)
tree9e78abd003568a5f554962d6c4a4942c8600a14e /sys
parentd943cf7d510a2b42fe3ea82d18118d8842e35214 (diff)
downloadFreeBSD-src-1ec02223897c43798625b70595c5897706ddaf52.zip
FreeBSD-src-1ec02223897c43798625b70595c5897706ddaf52.tar.gz
Remove safety belt: it is now ok to do a mtx_trylock() on a mutex you
already own. The mtx_trylock() will fail however. Enhance the comment at the top of the try lock function to explain this. Requested by: jlemon and his evil netisr locking
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_mutex.c9
-rw-r--r--sys/kern/subr_turnstile.c9
2 files changed, 8 insertions, 10 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index d2d907f..9f59577 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -454,8 +454,10 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int 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.
+ * Tries to acquire lock `m.' We do NOT handle recursion here. If this
+ * function is called on a recursed mutex, it will return failure and
+ * will not recursively acquire the lock. You are expected to know what
+ * you are doing.
*/
int
_mtx_trylock(struct mtx *m, int opts, const char *file, int line)
@@ -464,9 +466,6 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line)
MPASS(curthread != NULL);
- KASSERT(!mtx_owned(m),
- ("mtx_trylock() called on a mutex already owned"));
-
rval = _obtain_lock(m, curthread);
LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line);
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index d2d907f..9f59577 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.c
@@ -454,8 +454,10 @@ _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int 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.
+ * Tries to acquire lock `m.' We do NOT handle recursion here. If this
+ * function is called on a recursed mutex, it will return failure and
+ * will not recursively acquire the lock. You are expected to know what
+ * you are doing.
*/
int
_mtx_trylock(struct mtx *m, int opts, const char *file, int line)
@@ -464,9 +466,6 @@ _mtx_trylock(struct mtx *m, int opts, const char *file, int line)
MPASS(curthread != NULL);
- KASSERT(!mtx_owned(m),
- ("mtx_trylock() called on a mutex already owned"));
-
rval = _obtain_lock(m, curthread);
LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line);
OpenPOWER on IntegriCloud