diff options
author | melifaro <melifaro@FreeBSD.org> | 2012-03-26 09:34:17 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2012-03-26 09:34:17 +0000 |
commit | fd561480db34c3cacc88ece00cce76c6dd422eca (patch) | |
tree | d4649d8e9dbd56ee9b1ecddc94a142edd3887823 /sys/kern/kern_event.c | |
parent | 72dcb65231efbb0d266e4f5eee4753de4b5b8394 (diff) | |
download | FreeBSD-src-fd561480db34c3cacc88ece00cce76c6dd422eca.zip FreeBSD-src-fd561480db34c3cacc88ece00cce76c6dd422eca.tar.gz |
- Add knlist_init_rw_reader() function to kqueue(9).
Function acquired reader lock if needed.
Assert check for reader or writer lock (RA_LOCKED / RA_UNLOCKED)
- While here, add knlist_init_mtx.9 to MLINKS and fix some style(9) issues
Reviewed by: glebius
Approved by: ae(mentor)
MFC after: 2 weeks
Diffstat (limited to 'sys/kern/kern_event.c')
-rw-r--r-- | sys/kern/kern_event.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 925cbec..443d902 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/rwlock.h> #include <sys/proc.h> #include <sys/malloc.h> #include <sys/unistd.h> @@ -1869,6 +1870,7 @@ knlist_remove_inevent(struct knlist *knl, struct knote *kn) int knlist_empty(struct knlist *knl) { + KNL_ASSERT_LOCKED(knl); return SLIST_EMPTY(&knl->kl_list); } @@ -1882,27 +1884,59 @@ static void knlist_mtx_unlock(void *arg); static void knlist_mtx_lock(void *arg) { + mtx_lock((struct mtx *)arg); } static void knlist_mtx_unlock(void *arg) { + mtx_unlock((struct mtx *)arg); } static void knlist_mtx_assert_locked(void *arg) { + mtx_assert((struct mtx *)arg, MA_OWNED); } static void knlist_mtx_assert_unlocked(void *arg) { + mtx_assert((struct mtx *)arg, MA_NOTOWNED); } +static void +knlist_rw_rlock(void *arg) +{ + + rw_rlock((struct rwlock *)arg); +} + +static void +knlist_rw_runlock(void *arg) +{ + + rw_runlock((struct rwlock *)arg); +} + +static void +knlist_rw_assert_locked(void *arg) +{ + + rw_assert((struct rwlock *)arg, RA_LOCKED); +} + +static void +knlist_rw_assert_unlocked(void *arg) +{ + + rw_assert((struct rwlock *)arg, RA_UNLOCKED); +} + void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), void (*kl_unlock)(void *), @@ -1942,6 +1976,14 @@ knlist_init_mtx(struct knlist *knl, struct mtx *lock) } void +knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock) +{ + + knlist_init(knl, lock, knlist_rw_rlock, knlist_rw_runlock, + knlist_rw_assert_locked, knlist_rw_assert_unlocked); +} + +void knlist_destroy(struct knlist *knl) { |