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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Apr 23 12:19:58 2012 +0200

nucleus/sched: update scheduling class weights

This patch changes the respective weights of scheduling classes, in
order to give higher priority to classes whose threads are not
throttled by any sort of mechanism, over classes limiting the
execution time of their threads.

This gives us (in ascending priority order):

IDLE
   => TP
       => PSS
            => RT

The net effect is that runnable RT threads will always be picked by
the scheduler core before threads from other classes, which may be
throttled by some class-specific mechanism.

---

 include/nucleus/sched-rt.h    |    7 ++++---
 include/nucleus/sched.h       |    4 ++--
 ksrc/nucleus/sched-rt.c       |    2 +-
 ksrc/nucleus/sched-sporadic.c |    2 +-
 ksrc/nucleus/sched-tp.c       |    8 +++-----
 ksrc/nucleus/sched.c          |    8 ++++----
 6 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/include/nucleus/sched-rt.h b/include/nucleus/sched-rt.h
index 69c63ff..40a2011 100644
--- a/include/nucleus/sched-rt.h
+++ b/include/nucleus/sched-rt.h
@@ -48,9 +48,10 @@
 
 #if defined(__KERNEL__) || defined(__XENO_SIM__)
 
-#if defined(CONFIG_XENO_OPT_SCALABLE_SCHED) && \
-  XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS
-#error "RT class cannot use multi-level queue (too many priority levels)"
+#if XNSCHED_RT_NR_PRIO > XNSCHED_CLASS_MAX_PRIO ||     \
+  (defined(CONFIG_XENO_OPT_SCALABLE_SCHED) &&          \
+   XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS)
+#error "RT class has too many priority levels"
 #endif
 
 extern struct xnsched_class xnsched_class_rt;
diff --git a/include/nucleus/sched.h b/include/nucleus/sched.h
index df8853b..4657757 100644
--- a/include/nucleus/sched.h
+++ b/include/nucleus/sched.h
@@ -159,8 +159,8 @@ struct xnsched_class {
        const char *name;
 };
 
-#define XNSCHED_CLASS_MAX_THREADS      32768
-#define XNSCHED_CLASS_WEIGHT(n)                (n * XNSCHED_CLASS_MAX_THREADS)
+#define XNSCHED_CLASS_MAX_PRIO         1024
+#define XNSCHED_CLASS_WEIGHT(n)                (n * XNSCHED_CLASS_MAX_PRIO)
 
 /* Placeholder for current thread priority */
 #define XNSCHED_RUNPRIO   0x80000000
diff --git a/ksrc/nucleus/sched-rt.c b/ksrc/nucleus/sched-rt.c
index a182822..a167af6 100644
--- a/ksrc/nucleus/sched-rt.c
+++ b/ksrc/nucleus/sched-rt.c
@@ -302,7 +302,7 @@ struct xnsched_class xnsched_class_rt = {
        .sched_init_vfile       =       xnsched_rt_init_vfile,
        .sched_cleanup_vfile    =       xnsched_rt_cleanup_vfile,
 #endif
-       .weight                 =       XNSCHED_CLASS_WEIGHT(1),
+       .weight                 =       XNSCHED_CLASS_WEIGHT(3),
        .name                   =       "rt"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_rt);
diff --git a/ksrc/nucleus/sched-sporadic.c b/ksrc/nucleus/sched-sporadic.c
index ffc9bab..b890aae 100644
--- a/ksrc/nucleus/sched-sporadic.c
+++ b/ksrc/nucleus/sched-sporadic.c
@@ -588,7 +588,7 @@ struct xnsched_class xnsched_class_sporadic = {
        .sched_init_vfile       =       xnsched_sporadic_init_vfile,
        .sched_cleanup_vfile    =       xnsched_sporadic_cleanup_vfile,
 #endif
-       .weight                 =       XNSCHED_CLASS_WEIGHT(1),
+       .weight                 =       XNSCHED_CLASS_WEIGHT(2),
        .name                   =       "pss"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_sporadic);
diff --git a/ksrc/nucleus/sched-tp.c b/ksrc/nucleus/sched-tp.c
index a2af1d3..545bb4c 100644
--- a/ksrc/nucleus/sched-tp.c
+++ b/ksrc/nucleus/sched-tp.c
@@ -79,8 +79,7 @@ static void xnsched_tp_init(struct xnsched *sched)
 
        /*
         * Build the runqueues. Thread priorities for the TP policy
-        * are the same as RT priorities. TP is actually a superset of
-        * RT.
+        * are valid RT priorities. TP is actually a subset of RT.
         */
        for (n = 0; n < CONFIG_XENO_OPT_SCHED_TP_NRPART; n++)
                sched_initpq(&tp->partitions[n].runnable,
@@ -209,7 +208,7 @@ static void xnsched_tp_migrate(struct xnthread *thread, 
struct xnsched *sched)
        /*
         * Since our partition schedule is a per-scheduler property,
         * it cannot apply to a thread that moves to another CPU
-        * anymore. So we downgrade that thread to the RT class when a
+        * anymore. So we upgrade that thread to the RT class when a
         * CPU migration occurs. A subsequent call to
         * xnsched_set_policy() may move it back to TP scheduling,
         * with a partition assignment that fits the remote CPU's
@@ -287,7 +286,6 @@ struct vfile_sched_tp_priv {
        struct xnholder *curr;
 };
 
-
 struct vfile_sched_tp_data {
        int cpu;
        pid_t pid;
@@ -404,7 +402,7 @@ struct xnsched_class xnsched_class_tp = {
        .sched_init_vfile       =       xnsched_tp_init_vfile,
        .sched_cleanup_vfile    =       xnsched_tp_cleanup_vfile,
 #endif
-       .weight                 =       XNSCHED_CLASS_WEIGHT(2),
+       .weight                 =       XNSCHED_CLASS_WEIGHT(1),
        .name                   =       "tp"
 };
 EXPORT_SYMBOL_GPL(xnsched_class_tp);
diff --git a/ksrc/nucleus/sched.c b/ksrc/nucleus/sched.c
index b2d8de2..d2b9f86 100644
--- a/ksrc/nucleus/sched.c
+++ b/ksrc/nucleus/sched.c
@@ -51,13 +51,13 @@ static void xnsched_register_class(struct xnsched_class 
*sched_class)
 void xnsched_register_classes(void)
 {
        xnsched_register_class(&xnsched_class_idle);
-       xnsched_register_class(&xnsched_class_rt);
-#ifdef CONFIG_XENO_OPT_SCHED_SPORADIC
-       xnsched_register_class(&xnsched_class_sporadic);
-#endif
 #ifdef CONFIG_XENO_OPT_SCHED_TP
        xnsched_register_class(&xnsched_class_tp);
 #endif
+#ifdef CONFIG_XENO_OPT_SCHED_SPORADIC
+       xnsched_register_class(&xnsched_class_sporadic);
+#endif
+       xnsched_register_class(&xnsched_class_rt);
 }
 
 #ifdef CONFIG_XENO_OPT_WATCHDOG


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

Reply via email to