Module: xenomai-jki
Branch: for-upstream
Commit: 42a706d4945b7095e709db3ffb16756d6d800c5f
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=42a706d4945b7095e709db3ffb16756d6d800c5f

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Nov  4 15:10:37 2010 +0100

nucleus: Optimize reschedule signaling for UP

In UP mode, we do not need to fiddle with xnpod::resched at all and can
simply drop this field.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/nucleus/sched.h |   29 +++++++++++++++++++++--------
 ksrc/nucleus/pod.c      |   10 +++++++---
 ksrc/nucleus/sched.c    |    2 ++
 3 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/include/nucleus/sched.h b/include/nucleus/sched.h
index 548f0f1..0be74e8 100644
--- a/include/nucleus/sched.h
+++ b/include/nucleus/sched.h
@@ -63,7 +63,9 @@ typedef struct xnsched {
        xnflags_t status;               /*!< Scheduler specific status bitmask. 
*/
        int cpu;
        struct xnthread *curr;          /*!< Current thread. */
+#ifdef CONFIG_SMP
        xnarch_cpumask_t resched;       /*!< Mask of CPUs needing rescheduling. 
*/
+#endif
 
        struct xnsched_rt rt;           /*!< Context of built-in real-time 
class. */
 #ifdef CONFIG_XENO_OPT_SCHED_TP
@@ -170,19 +172,30 @@ static inline int xnsched_resched_p(struct xnsched *sched)
        return testbits(sched->status, XNRESCHED);
 }
 
-/* Set self resched flag for the given scheduler. */
-#define xnsched_set_self_resched(__sched__) do {               \
-  xnarch_cpu_set(xnsched_cpu(__sched__), (__sched__)->resched); \
-  __setbits((__sched__)->status, XNRESCHED);                   \
-} while (0)
+#ifdef CONFIG_SMP
 
 /* Set specific resched flag into the local scheduler mask. */
+#define xnsched_set_self_resched(__sched__) do {                       \
+       XENO_BUGON(NUCLEUS, __sched__ != xnpod_current_sched());        \
+       xnarch_cpu_set(xnsched_cpu(__sched__), (__sched__)->resched);   \
+       __setbits((__sched__)->status, XNRESCHED);                      \
+} while (0)
+
+/* Set self resched flag for the given scheduler. */
 #define xnsched_set_resched(__sched__) do {                            \
-  xnsched_t *current_sched = xnpod_current_sched();                    \
-  xnarch_cpu_set(xnsched_cpu(__sched__), current_sched->resched);      \
-  __setbits(current_sched->status, XNRESCHED);                         \
+       xnsched_t *current_sched = xnpod_current_sched();               \
+       xnarch_cpu_set(xnsched_cpu(__sched__), current_sched->resched); \
+       __setbits(current_sched->status, XNRESCHED);                    \
 } while (0)
 
+#else /* !CONFIG_SMP */
+
+#define xnsched_set_self_resched(__sched__)    \
+       __setbits((__sched__)->status, XNRESCHED)
+#define xnsched_set_resched    xnsched_set_self_resched
+
+#endif /* !CONFIG_SMP */
+
 void xnsched_zombie_hooks(struct xnthread *thread);
 
 void __xnsched_finalize_zombie(struct xnsched *sched);
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index afb60b4..6dd279c 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -2169,16 +2169,20 @@ static inline void xnpod_switch_to(xnsched_t *sched,
 
 static inline int __xnpod_test_resched(struct xnsched *sched)
 {
-       int cpu = xnsched_cpu(sched), resched;
+       int resched;
+#ifdef CONFIG_SMP
+       int cpu = xnsched_cpu(sched);
 
        resched = xnarch_cpu_isset(cpu, sched->resched);
-       xnarch_cpu_clear(cpu, sched->resched);
-#ifdef CONFIG_SMP
+
        /* Send resched IPI to remote CPU(s). */
+       xnarch_cpu_clear(cpu, sched->resched);
        if (unlikely(!xnarch_cpus_empty(sched->resched))) {
                xnarch_send_ipi(sched->resched);
                xnarch_cpus_clear(sched->resched);
        }
+#else
+       resched = xnsched_resched_p(sched);
 #endif
        __clrbits(sched->status, XNRESCHED);
        return resched;
diff --git a/ksrc/nucleus/sched.c b/ksrc/nucleus/sched.c
index 04a344e..04b3727 100644
--- a/ksrc/nucleus/sched.c
+++ b/ksrc/nucleus/sched.c
@@ -152,7 +152,9 @@ void xnsched_init(struct xnsched *sched, int cpu)
        xntimer_set_name(&sched->htimer, htimer_name);
        xntimer_set_sched(&sched->htimer, sched);
        sched->zombie = NULL;
+#ifdef CONFIG_SMP
        xnarch_cpus_clear(sched->resched);
+#endif
 
        attr.flags = XNROOT | XNSTARTED | XNFPU;
        attr.name = root_name;


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

Reply via email to