From 1a109c1cb0ef3176d2d32e11d8a51d48248bd2e5 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Fri, 29 May 2009 10:52:37 +0000 Subject: Make the rmlock(9) interface a bit more like the rwlock(9) interface: - Add rm_init_flags() and accept extended options only for that variation. - Add a flags space specifically for rm_init_flags(), rather than borrowing the lock_init() flag space. - Define flag RM_RECURSE to use instead of LO_RECURSABLE. - Define flag RM_NOWITNESS to allow an rmlock to be exempt from WITNESS checking; this wasn't possible previously as rm_init() always passed LO_WITNESS when initializing an rmlock's struct lock. - Add RM_SYSINIT_FLAGS(). - Rename embedded mutex in rmlocks to make it more obvious what it is. - Update consumers. - Update man page. --- sys/kern/kern_rmlock.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'sys/kern/kern_rmlock.c') diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 3d0a10df2f09..6b83caf11015 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -188,14 +188,26 @@ rm_cleanIPI(void *arg) } void -rm_init(struct rmlock *rm, const char *name, int opts) +rm_init_flags(struct rmlock *rm, const char *name, int opts) { + int liflags; + liflags = 0; + if (!(opts & RM_NOWITNESS)) + liflags |= LO_WITNESS; + if (opts & RM_RECURSE) + liflags |= LO_RECURSABLE; rm->rm_noreadtoken = 1; LIST_INIT(&rm->rm_activeReaders); - mtx_init(&rm->rm_lock, name, "RM_MTX",MTX_NOWITNESS); - lock_init(&rm->lock_object, &lock_class_rm, name, NULL, - (opts & LO_RECURSABLE)| LO_WITNESS); + mtx_init(&rm->rm_lock, name, "rmlock_mtx", MTX_NOWITNESS); + lock_init(&rm->lock_object, &lock_class_rm, name, NULL, liflags); +} + +void +rm_init(struct rmlock *rm, const char *name) +{ + + rm_init_flags(rm, name, 0); } void @@ -216,9 +228,17 @@ rm_wowned(struct rmlock *rm) void rm_sysinit(void *arg) { - struct rm_args *args = arg; - rm_init(args->ra_rm, args->ra_desc, args->ra_opts); + + rm_init(args->ra_rm, args->ra_desc); +} + +void +rm_sysinit_flags(void *arg) +{ + struct rm_args_flags *args = arg; + + rm_init_flags(args->ra_rm, args->ra_desc, args->ra_opts); } static void -- cgit v1.2.3