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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue May 20 18:21:55 2014 +0200

cobalt/sched: increase the visible priority range of real-time classes

There is no point in limiting the available priority range to 99 for
all classes but SCHED_COBALT, although we support up to 258 distinct
levels internally.

POSIX explicitly states that such limit is implementation-dependent,
and provides for sched_get_priority_max() for retrieving it
dynamically. Applications wary of portability between the Cobalt and
Mercury cores should probe for such limit.

All real-time classes exposed to userland now support up to 256 levels
[0..255], except SCHED_COBALT which gives access to the widest range
[0..257] available internally.

---

 doc/asciidoc/MIGRATION.adoc         |   16 +++++++++++++---
 include/cobalt/kernel/rtdm/driver.h |    2 +-
 include/cobalt/kernel/sched-rt.h    |    8 ++++----
 lib/cobalt/thread.c                 |   20 ++++++++++----------
 4 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/doc/asciidoc/MIGRATION.adoc b/doc/asciidoc/MIGRATION.adoc
index cd2a1a4..650a6f4 100644
--- a/doc/asciidoc/MIGRATION.adoc
+++ b/doc/asciidoc/MIGRATION.adoc
@@ -381,9 +381,19 @@ using the Cobalt core.
 
 .Scheduling
 
-- Calling +pthread_setschedparam()+ may cause a secondary mode switch
-  for the caller, but does not cause any mode switch for the target
-  thread unlike with Xenomai 2.x.
+- +sched_get_priority_max()+ returns a larger value for all real-time
+  policies over Cobalt, compared to their Mercury counterpart, which
+  are directly mapped over the native Linux scheduling policies
+  instead (e.g. 255 vs 99 for SCHED_FIFO/RR). Applications wary of
+  portability between the Cobalt and Mercury cores should probe for
+  such limit.
+
+- The +SCHED_SPORADIC+ and +SCHED_TP classes now support up to 255
+  priority levels, instead of 99 as previously with Xenomai 2.x.
+
+- +pthread_setschedparam()+ may cause a secondary mode switch for the
+  caller, but will not cause any mode switch for the target thread
+  unlike with Xenomai 2.x.
 
 [normal]
   This is a requirement for maintaining both the *glibc* and the
diff --git a/include/cobalt/kernel/rtdm/driver.h 
b/include/cobalt/kernel/rtdm/driver.h
index 6c805d8..b07f68f 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -1357,7 +1357,7 @@ typedef void (*rtdm_task_proc_t)(void *arg);
  * Maximum and minimum task priorities
  * @{ */
 #define RTDM_TASK_LOWEST_PRIORITY      0
-#define RTDM_TASK_HIGHEST_PRIORITY     XNSCHED_FIFO_MAX_PRIO
+#define RTDM_TASK_HIGHEST_PRIORITY     99
 /** @} Task Priority Range */
 
 /**
diff --git a/include/cobalt/kernel/sched-rt.h b/include/cobalt/kernel/sched-rt.h
index 4655ac9..48642bd 100644
--- a/include/cobalt/kernel/sched-rt.h
+++ b/include/cobalt/kernel/sched-rt.h
@@ -28,8 +28,8 @@
 #endif
 
 /*
- * Global priority scale for Xenomai's RT scheduling class, available
- * to SCHED_COBALT members.
+ * Global priority scale for Xenomai's core scheduling class,
+ * available to SCHED_COBALT members.
  */
 #define XNSCHED_RT_MIN_PRIO    0
 #define XNSCHED_RT_MAX_PRIO    257
@@ -40,12 +40,12 @@
  * except SCHED_COBALT.
  */
 #define XNSCHED_FIFO_MIN_PRIO  1
-#define XNSCHED_FIFO_MAX_PRIO  99
+#define XNSCHED_FIFO_MAX_PRIO  255
 
 #if XNSCHED_RT_NR_PRIO > XNSCHED_CLASS_WEIGHT_FACTOR ||        \
   (defined(CONFIG_XENO_OPT_SCALABLE_SCHED) &&          \
    XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS)
-#error "RT class has too many priority levels"
+#error "SCHED_COBALT has too many priority levels"
 #endif
 
 extern struct xnsched_class xnsched_class_rt;
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 0d7d7c8..135906a 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -56,21 +56,21 @@ static int libc_setschedparam(pthread_t thread,
        case SCHED_WEAK:
                policy = priority ? SCHED_FIFO : SCHED_OTHER;
                break;
-       case SCHED_COBALT:
-       case SCHED_TP:
-       case SCHED_SPORADIC:
-       case SCHED_QUOTA:
+       default:
                policy = SCHED_FIFO;
+               /* falldown wanted. */
+       case SCHED_FIFO:
+       case SCHED_RR:
                /*
-                * Our priority range is larger than the regular
-                * kernel's, limit the priority value accordingly.
+                * The Cobalt priority range is larger than those of
+                * the native SCHED_FIFO/RR classes, so we have to cap
+                * the priority value accordingly.  We also remap
+                * "weak" (negative) priorities - which are only
+                * meaningful for the Cobalt core - to regular values.
                 */
                if (priority > std_maxpri)
                        priority = std_maxpri;
-               break;
-       default:
-               policy = policy_ex;
-               if (priority < 0)
+               else if (priority < 0)
                        priority = -priority;
        }
 


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

Reply via email to