diff options
author | John Baldwin <jhb@FreeBSD.org> | 2007-03-09 16:27:11 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2007-03-09 16:27:11 +0000 |
commit | 6e21afd40ca27a1aaef83296fa1e46fbc5e48017 (patch) | |
tree | 71366da8c5df1e7210aad9d816166233c0107eff /sys/sys/lock.h | |
parent | f9feee175baa10825785cf7f2e596170612ae15d (diff) | |
download | src-6e21afd40ca27a1aaef83296fa1e46fbc5e48017.tar.gz src-6e21afd40ca27a1aaef83296fa1e46fbc5e48017.zip |
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.
Notes
Notes:
svn path=/head/; revision=167368
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 a30a595f03c6..3a3b4d28a3b8 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. */ |