diff options
author | jhb <jhb@FreeBSD.org> | 2007-03-09 16:27:11 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2007-03-09 16:27:11 +0000 |
commit | 60ad130f466f4ce8bb90b4d47775516afbfb2e48 (patch) | |
tree | 71366da8c5df1e7210aad9d816166233c0107eff /sys/sys/lock.h | |
parent | b03e9e93edda2ff558f1eb141e812c32a2931dc2 (diff) | |
download | FreeBSD-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/sys/lock.h')
-rw-r--r-- | sys/sys/lock.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/sys/lock.h b/sys/sys/lock.h index a30a595..3a3b4d2 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -45,12 +45,21 @@ struct thread; * an error to perform any type of context switch while holding a spin lock. * Also, for an individual lock to be recursable, its class must allow * recursion and the lock itself must explicitly allow recursion. + * + * The 'lc_ddb_show' function pointer is used to dump class-specific + * data for the 'show lock' DDB command. The 'lc_lock' and + * 'lc_unlock' function pointers are used in sleep(9) and cv_wait(9) + * to lock and unlock locks while blocking on a sleep queue. The + * return value of 'lc_unlock' will be passed to 'lc_lock' on resume + * to allow communication of state between the two routines. */ struct lock_class { const char *lc_name; u_int lc_flags; void (*lc_ddb_show)(struct lock_object *lock); + void (*lc_lock)(struct lock_object *lock, int how); + int (*lc_unlock)(struct lock_object *lock); }; #define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */ |