summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_lock.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-03-09 16:27:11 +0000
committerjhb <jhb@FreeBSD.org>2007-03-09 16:27:11 +0000
commit60ad130f466f4ce8bb90b4d47775516afbfb2e48 (patch)
tree71366da8c5df1e7210aad9d816166233c0107eff /sys/kern/kern_lock.c
parentb03e9e93edda2ff558f1eb141e812c32a2931dc2 (diff)
downloadFreeBSD-src-60ad130f466f4ce8bb90b4d47775516afbfb2e48.zip
FreeBSD-src-60ad130f466f4ce8bb90b4d47775516afbfb2e48.tar.gz
Add two new function pointers 'lc_lock' and 'lc_unlock' to lock classes.
These functions are intended to be used to drop a lock and then reacquire it when doing an sleep such as msleep(9). Both functions accept a 'struct lock_object *' as their first parameter. The 'lc_unlock' function returns an integer that is then passed as the second paramter to the subsequent 'lc_lock' function. This can be used to communicate state. For example, sx locks and rwlocks use this to indicate if the lock was share/read locked vs exclusive/write locked. Currently, spin mutexes and lockmgr locks do not provide working lc_lock and lc_unlock functions.
Diffstat (limited to 'sys/kern/kern_lock.c')
-rw-r--r--sys/kern/kern_lock.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 8533836..02254a4 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -64,22 +64,38 @@ __FBSDID("$FreeBSD$");
#include <ddb/ddb.h>
static void db_show_lockmgr(struct lock_object *lock);
#endif
-
+static void lock_lockmgr(struct lock_object *lock, int how);
+static int unlock_lockmgr(struct lock_object *lock);
struct lock_class lock_class_lockmgr = {
.lc_name = "lockmgr",
.lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
#ifdef DDB
- .lc_ddb_show = db_show_lockmgr
+ .lc_ddb_show = db_show_lockmgr,
#endif
+ .lc_lock = lock_lockmgr,
+ .lc_unlock = unlock_lockmgr,
};
-
/*
* Locking primitives implementation.
* Locks provide shared/exclusive sychronization.
*/
+void
+lock_lockmgr(struct lock_object *lock, int how)
+{
+
+ panic("lockmgr locks do not support sleep interlocking");
+}
+
+int
+unlock_lockmgr(struct lock_object *lock)
+{
+
+ panic("lockmgr locks do not support sleep interlocking");
+}
+
#define COUNT(td, x) if ((td)) (td)->td_locks += (x)
#define LK_ALL (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE | \
LK_SHARE_NONZERO | LK_WAIT_NONZERO)
OpenPOWER on IntegriCloud