summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sx.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-01-17 16:55:17 +0000
committerjhb <jhb@FreeBSD.org>2006-01-17 16:55:17 +0000
commitc0cf4870f410060c24b4fada37aa68f397098325 (patch)
tree39ef317a70787cab889c6304585f543a64e07ebc /sys/kern/kern_sx.c
parentb12ec6b7ed4f791a27a5b65c12d5e1f21fa43ece (diff)
downloadFreeBSD-src-c0cf4870f410060c24b4fada37aa68f397098325.zip
FreeBSD-src-c0cf4870f410060c24b4fada37aa68f397098325.tar.gz
Add a new file (kern/subr_lock.c) for holding code related to struct
lock_obj objects: - Add new lock_init() and lock_destroy() functions to setup and teardown lock_object objects including KTR logging and registering with WITNESS. - Move all the handling of LO_INITIALIZED out of witness and the various lock init functions into lock_init() and lock_destroy(). - Remove the constants for static indices into the lock_classes[] array and change the code outside of subr_lock.c to use LOCK_CLASS to compare against a known lock class. - Move the 'show lock' ddb function and lock_classes[] array out of kern_mutex.c over to subr_lock.c.
Diffstat (limited to 'sys/kern/kern_sx.c')
-rw-r--r--sys/kern/kern_sx.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index d24e4de..a3a7da8 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -77,16 +77,7 @@ sx_sysinit(void *arg)
void
sx_init(struct sx *sx, const char *description)
{
- struct lock_object *lock;
-
- lock = &sx->sx_object;
- KASSERT((lock->lo_flags & LO_INITIALIZED) == 0,
- ("sx lock %s %p already initialized", description, sx));
- bzero(sx, sizeof(*sx));
- lock->lo_flags = LOCK_CLASS_SX << LO_CLASSSHIFT;
- lock->lo_type = lock->lo_name = description;
- lock->lo_flags |= LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE |
- LO_UPGRADABLE;
+
sx->sx_lock = mtx_pool_find(mtxpool_lockbuilder, sx);
sx->sx_cnt = 0;
cv_init(&sx->sx_shrd_cv, description);
@@ -94,18 +85,14 @@ sx_init(struct sx *sx, const char *description)
cv_init(&sx->sx_excl_cv, description);
sx->sx_excl_wcnt = 0;
sx->sx_xholder = NULL;
-
- LOCK_LOG_INIT(lock, 0);
-
- WITNESS_INIT(lock);
+ lock_init(&sx->sx_object, &lock_class_sx, description, NULL,
+ LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE | LO_UPGRADABLE);
}
void
sx_destroy(struct sx *sx)
{
- LOCK_LOG_DESTROY(&sx->sx_object, 0);
-
KASSERT((sx->sx_cnt == 0 && sx->sx_shrd_wcnt == 0 && sx->sx_excl_wcnt ==
0), ("%s (%s): holders or waiters\n", __func__,
sx->sx_object.lo_name));
@@ -114,7 +101,7 @@ sx_destroy(struct sx *sx)
cv_destroy(&sx->sx_shrd_cv);
cv_destroy(&sx->sx_excl_cv);
- WITNESS_DESTROY(&sx->sx_object);
+ lock_destroy(&sx->sx_object);
}
void
OpenPOWER on IntegriCloud