Module: xenomai-forge Branch: master Commit: 48abc05a9e9e043114f3d55b9db16a47ef74ffaf URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=48abc05a9e9e043114f3d55b9db16a47ef74ffaf
Author: Philippe Gerum <r...@xenomai.org> Date: Wed Nov 23 19:28:09 2011 +0100 cobalt/nucleus: introduce xnsynch_wakeup_many_sleepers() --- include/cobalt/nucleus/synch.h | 2 ++ kernel/cobalt/nucleus/synch.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/include/cobalt/nucleus/synch.h b/include/cobalt/nucleus/synch.h index fa05dfd..be56dde 100644 --- a/include/cobalt/nucleus/synch.h +++ b/include/cobalt/nucleus/synch.h @@ -179,6 +179,8 @@ xnflags_t xnsynch_sleep_on(struct xnsynch *synch, struct xnthread *xnsynch_wakeup_one_sleeper(struct xnsynch *synch); +int xnsynch_wakeup_many_sleepers(struct xnsynch *synch, int nr); + xnpholder_t *xnsynch_wakeup_this_sleeper(struct xnsynch *synch, xnpholder_t *holder); diff --git a/kernel/cobalt/nucleus/synch.c b/kernel/cobalt/nucleus/synch.c index 08315d8..b501169 100644 --- a/kernel/cobalt/nucleus/synch.c +++ b/kernel/cobalt/nucleus/synch.c @@ -260,6 +260,41 @@ struct xnthread *xnsynch_wakeup_one_sleeper(struct xnsynch *synch) } EXPORT_SYMBOL_GPL(xnsynch_wakeup_one_sleeper); +int xnsynch_wakeup_many_sleepers(struct xnsynch *synch, int nr) +{ + struct xnpholder *holder; + struct xnthread *thread; + int ret = 0; + spl_t s; + + XENO_BUGON(NUCLEUS, testbits(synch->status, XNSYNCH_OWNER)); + + xnlock_get_irqsave(&nklock, s); + + for (;;) { + if (nr >= ret) + break; + holder = getpq(&synch->pendq); + if (holder == NULL) + break; + + thread = link2thread(holder, plink); + thread->wchan = NULL; + trace_mark(xn_nucleus, synch_wakeup_many, + "thread %p thread_name %s synch %p", + thread, xnthread_name(thread), synch); + xnpod_resume_thread(thread, XNPEND); + ret++; + } + + xnlock_put_irqrestore(&nklock, s); + + xnarch_post_graph_if(synch, 0, emptypq_p(&synch->pendq)); + + return ret; +} +EXPORT_SYMBOL_GPL(xnsynch_wakeup_many_sleepers); + /*! * \fn void xnsynch_wakeup_this_sleeper(struct xnsynch *synch, struct xnpholder *holder); * \brief Give the resource ownership to a given waiting thread. _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git