Module: xenomai-forge
Branch: master
Commit: c1b30ab1ac990c2698ec34649c3725233b2e3b74
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=c1b30ab1ac990c2698ec34649c3725233b2e3b74

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Mon Dec  5 20:39:52 2011 +0100

cobalt/synch: rework xnsynch_wakeup_many_sleepers

---

 kernel/cobalt/nucleus/synch.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/cobalt/nucleus/synch.c b/kernel/cobalt/nucleus/synch.c
index 50f3cc3..54a602f 100644
--- a/kernel/cobalt/nucleus/synch.c
+++ b/kernel/cobalt/nucleus/synch.c
@@ -264,19 +264,18 @@ int xnsynch_wakeup_many_sleepers(struct xnsynch *synch, 
int nr)
 {
        struct xnpholder *holder;
        struct xnthread *thread;
-       int ret = 0;
+       int sleepers, i;
        spl_t s;
 
        XENO_BUGON(NUCLEUS, testbits(synch->status, XNSYNCH_OWNER));
 
        xnlock_get_irqsave(&nklock, s);
 
-       for (;;) {
-               if (nr >= ret)
-                       break;
+       sleepers = xnsynch_nsleepers(synch);
+       if (nr > sleepers)
+               nr = sleepers;
+       for (i = 0; i < nr; i++) {
                holder = getpq(&synch->pendq);
-               if (holder == NULL)
-                       break;
 
                thread = link2thread(holder, plink);
                thread->wchan = NULL;
@@ -284,14 +283,13 @@ int xnsynch_wakeup_many_sleepers(struct xnsynch *synch, 
int nr)
                           "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;
+       return nr;
 }
 EXPORT_SYMBOL_GPL(xnsynch_wakeup_many_sleepers);
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to