diff options
author | alfred <alfred@FreeBSD.org> | 2002-04-02 04:18:54 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-04-02 04:18:54 +0000 |
commit | cb408d85e76131d8ac5262acf46420d22794ca11 (patch) | |
tree | b808fbe52b573b678cf28d5b5d3c29c03897aa7a /sys | |
parent | ab6bb4225e38a33e34980df6d09894466928b3f1 (diff) | |
download | FreeBSD-src-cb408d85e76131d8ac5262acf46420d22794ca11.zip FreeBSD-src-cb408d85e76131d8ac5262acf46420d22794ca11.tar.gz |
Use sx locks rather than lockmgr locks for eventhandlers.
Submitted by: Jonathan Mini <mini@haikugeek.com>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_eventhandler.c | 11 | ||||
-rw-r--r-- | sys/sys/eventhandler.h | 23 |
2 files changed, 16 insertions, 18 deletions
diff --git a/sys/kern/subr_eventhandler.c b/sys/kern/subr_eventhandler.c index f02fb33..5cb2500 100644 --- a/sys/kern/subr_eventhandler.c +++ b/sys/kern/subr_eventhandler.c @@ -90,6 +90,7 @@ eventhandler_register(struct eventhandler_list *list, char *name, return(NULL); } list->el_flags = 0; + bzero(&list->el_lock, sizeof(list->el_lock)); list->el_name = (char *)list + sizeof(struct eventhandler_list); strcpy(list->el_name, name); TAILQ_INSERT_HEAD(&eventhandler_lists, list, el_link); @@ -97,7 +98,7 @@ eventhandler_register(struct eventhandler_list *list, char *name, } if (!(list->el_flags & EHE_INITTED)) { TAILQ_INIT(&list->el_entries); - lockinit(&list->el_lock, PZERO, name, 0, 0); + sx_init(&list->el_lock, name); list->el_flags = EHE_INITTED; } @@ -112,7 +113,7 @@ eventhandler_register(struct eventhandler_list *list, char *name, eg->ee.ee_priority = priority; /* sort it into the list */ - lockmgr(&list->el_lock, LK_EXCLUSIVE, NULL, curthread); + EHE_LOCK(list); for (ep = TAILQ_FIRST(&list->el_entries); ep != NULL; ep = TAILQ_NEXT(ep, ee_link)) { @@ -123,7 +124,7 @@ eventhandler_register(struct eventhandler_list *list, char *name, } if (ep == NULL) TAILQ_INSERT_TAIL(&list->el_entries, &eg->ee, ee_link); - lockmgr(&list->el_lock, LK_RELEASE, NULL, curthread); + EHE_UNLOCK(list); mtx_unlock(&eventhandler_mutex); return(&eg->ee); } @@ -134,7 +135,7 @@ eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) struct eventhandler_entry *ep = tag; /* XXX insert diagnostic check here? */ - lockmgr(&list->el_lock, LK_EXCLUSIVE, NULL, curthread); + EHE_LOCK(list); if (ep != NULL) { /* remove just this entry */ TAILQ_REMOVE(&list->el_entries, ep, ee_link); @@ -147,7 +148,7 @@ eventhandler_deregister(struct eventhandler_list *list, eventhandler_tag tag) free(ep, M_EVENTHANDLER); } } - lockmgr(&list->el_lock, LK_RELEASE, NULL, curthread); + EHE_UNLOCK(list); } struct eventhandler_list * diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h index 7476b7d..bc03fc9 100644 --- a/sys/sys/eventhandler.h +++ b/sys/sys/eventhandler.h @@ -29,15 +29,9 @@ #ifndef SYS_EVENTHANDLER_H #define SYS_EVENTHANDLER_H -/* - * XXX - compatability until lockmgr() goes away or all the #includes are - * updated. - */ -#include <sys/lockmgr.h> - +#include <sys/lock.h> +#include <sys/sx.h> #include <sys/queue.h> -#include <sys/_lock.h> -#include <sys/_mutex.h> struct eventhandler_entry { @@ -51,13 +45,16 @@ struct eventhandler_list char *el_name; int el_flags; #define EHE_INITTED (1<<0) - struct lock el_lock; + struct sx el_lock; TAILQ_ENTRY(eventhandler_list) el_link; TAILQ_HEAD(,eventhandler_entry) el_entries; }; typedef struct eventhandler_entry *eventhandler_tag; +#define EHE_LOCK(p) sx_xlock(&(p)->el_lock) +#define EHE_UNLOCK(p) sx_xunlock(&(p)->el_lock) + /* * Fast handler lists require the eventhandler list be present * at link time. They don't allow addition of entries to @@ -87,7 +84,7 @@ do { \ struct eventhandler_entry *_ep, *_en; \ \ if (_el->el_flags & EHE_INITTED) { \ - lockmgr(&_el->el_lock, LK_EXCLUSIVE, NULL, curthread); \ + EHE_LOCK(_el); \ _ep = TAILQ_FIRST(&(_el->el_entries)); \ while (_ep != NULL) { \ _en = TAILQ_NEXT(_ep, ee_link); \ @@ -95,7 +92,7 @@ do { \ ## args); \ _ep = _en; \ } \ - lockmgr(&_el->el_lock, LK_RELEASE, NULL, curthread); \ + EHE_UNLOCK(_el); \ } \ } while (0) @@ -127,7 +124,7 @@ do { \ \ if (((_el = eventhandler_find_list(#name)) != NULL) && \ (_el->el_flags & EHE_INITTED)) { \ - lockmgr(&_el->el_lock, LK_EXCLUSIVE, NULL, curthread); \ + EHE_LOCK(_el); \ _ep = TAILQ_FIRST(&(_el->el_entries)); \ while (_ep != NULL) { \ _en = TAILQ_NEXT(_ep, ee_link); \ @@ -135,7 +132,7 @@ do { \ ## args); \ _ep = _en; \ } \ - lockmgr(&_el->el_lock, LK_RELEASE, NULL, curthread); \ + EHE_UNLOCK(_el); \ } \ } while (0) |