From 60ad130f466f4ce8bb90b4d47775516afbfb2e48 Mon Sep 17 00:00:00 2001 From: jhb Date: Fri, 9 Mar 2007 16:27:11 +0000 Subject: 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. --- sys/kern/kern_lock.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'sys/kern/kern_lock.c') 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 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) -- cgit v1.1