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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Aug 30 14:47:10 2013 +0200

cobalt/sched: return switch flag from xnsched_run()

---

 include/cobalt/kernel/sched.h |   13 ++++++-------
 kernel/cobalt/sched.c         |   13 +++++++++----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index dc68c3f..eb1bb0c 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -244,11 +244,11 @@ static inline int xnsched_supported_cpu(int cpu)
        for_each_online_cpu(cpu)                \
                if (xnsched_supported_cpu(cpu)) \
 
-void __xnsched_run(struct xnsched *sched);
+int __xnsched_run(struct xnsched *sched);
 
 void __xnsched_run_handler(void);
 
-static inline void xnsched_run(void)
+static inline int xnsched_run(void)
 {
        struct xnsched *sched;
        /*
@@ -278,16 +278,15 @@ static inline void xnsched_run(void)
         * context switch.
         */
 #if XENO_DEBUG(NUCLEUS)
-       if ((sched->status|sched->lflags) &
-           (XNINIRQ|XNINSW|XNINLOCK))
-               return;
+       if ((sched->status|sched->lflags) & (XNINIRQ|XNINSW|XNINLOCK))
+               return 0;
 #else /* !XENO_DEBUG(NUCLEUS) */
        if (((sched->status|sched->lflags) &
             (XNINIRQ|XNINSW|XNRESCHED|XNINLOCK)) != XNRESCHED)
-               return;
+               return 0;
 #endif /* !XENO_DEBUG(NUCLEUS) */
 
-       __xnsched_run(sched);
+       return __xnsched_run(sched);
 }
 
 void ___xnsched_lock(struct xnsched *sched);
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index eeeab7e..2f4f022 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -607,7 +607,7 @@ static inline void switch_context(struct xnsched *sched,
 }
 
 /**
- * @fn void xnsched_run(void)
+ * @fn int xnsched_run(void)
  * @brief The rescheduling procedure.
  *
  * This is the central rescheduling routine which should be called to
@@ -652,6 +652,9 @@ static inline void switch_context(struct xnsched *sched,
  * Calling this procedure with no applicable context switch pending is
  * harmless and simply leads to a null-effect.
  *
+ * @return Non-zero is returned if a context switch actually happened,
+ * otherwise zero if the current thread was left running.
+ *
  * Environments:
  *
  * This service can be called from any context.
@@ -708,14 +711,14 @@ void __xnsched_run_handler(void) /* hw interrupts off. */
        xnsched_run();
 }
 
-void __xnsched_run(struct xnsched *sched)
+int __xnsched_run(struct xnsched *sched)
 {
        struct xnthread *prev, *next, *curr;
        int switched, need_resched, shadow;
        spl_t s;
 
        if (xnarch_escalate())
-               return;
+               return 0;
 
        trace_mark(xn_nucleus, sched, MARK_NOARGS);
 
@@ -808,7 +811,7 @@ signal_unlock_and_exit:
 
        xnlock_put_irqrestore(&nklock, s);
 
-       return;
+       return switched;
 
 shadow_epilogue:
 
@@ -833,6 +836,8 @@ shadow_epilogue:
         * xnthread_suspend() when relaxing a thread.
         */
        XENO_BUGON(NUCLEUS, !hard_irqs_disabled());
+
+       return 1;
 }
 EXPORT_SYMBOL_GPL(__xnsched_run);
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to