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

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..2824b45 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 < sleepers; 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