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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon May 26 10:03:51 2014 +0200

copperplate: substitute SCHED_RT with SCHED_FIFO

Now that Cobalt supports up to 256 priority levels with the SCHED_FIFO
class, we may assign all regular real-time threads directly to the
latter.

SCHED_CORE is introduced as an alias to the scheduling class giving
access to the highest priority levels assigned to internal server
threads.

---

 include/copperplate/threadobj.h  |    4 ++--
 lib/alchemy/task.c               |   20 ++++++++++----------
 lib/copperplate/regd/fs-common.c |    4 ++--
 lib/copperplate/threadobj.c      |    8 ++++----
 lib/copperplate/timerobj.c       |    2 +-
 lib/psos/task.c                  |   36 +++++++++++++++++-------------------
 lib/vxworks/taskLib.c            |   35 ++++++++++++++++-------------------
 7 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index 44d1047..b58196d 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -62,7 +62,7 @@ struct threadobj_stat {
        ticks_t timeout;
 };
 
-#define SCHED_RT  SCHED_COBALT
+#define SCHED_CORE  SCHED_COBALT
 
 static inline
 void threadobj_save_timeout(struct threadobj_corespec *corespec,
@@ -100,7 +100,7 @@ struct threadobj_stat {
        ticks_t timeout;
 };
 
-#define SCHED_RT  SCHED_FIFO
+#define SCHED_CORE  SCHED_FIFO
 
 static inline
 void threadobj_save_timeout(struct threadobj_corespec *corespec,
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 199d675..983cfef 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -319,8 +319,8 @@ fail_syncinit:
  *
  * This service creates a task with access to the full set of Xenomai
  * real-time services. If @a prio is non-zero, the new task belongs to
- * Xenomai's real-time FIFO scheduling class, aka SCHED_RT. If @a prio
- * is zero, the task belongs to the regular SCHED_OTHER class.
+ * Xenomai's real-time FIFO scheduling class, aka SCHED_FIFO. If @a
+ * prio is zero, the task belongs to the regular SCHED_OTHER class.
  *
  * Creating tasks with zero priority is useful for running non
  * real-time processes which may invoke blocking real-time services,
@@ -382,15 +382,15 @@ fail_syncinit:
  *
  * When running over the Cobalt core:
  *
- * - calling rt_task_create() causes SCHED_RT tasks to switch to
+ * - calling rt_task_create() causes SCHED_FIFO tasks to switch to
  * secondary mode.
  *
- * - members of Xenomai's SCHED_RT class running in the primary domain
- * have utmost priority over all Linux activities in the system,
- * including regular interrupt handlers.
+ * - members of Xenomai's SCHED_FIFO class running in the primary
+ * domain have utmost priority over all Linux activities in the
+ * system, including Linux interrupt handlers.
  *
- * When running over the Mercury core, the SCHED_RT class is mapped
- * over the regular POSIX SCHED_FIFO class.
+ * When running over the Mercury core, the new task belongs to the
+ * regular POSIX SCHED_FIFO class.
  *
  * @note Tasks can be referred to from multiple processes which all
  * belong to the same Xenomai session.
@@ -649,7 +649,7 @@ out:
  * process into a Xenomai-enabled task.
  *
  * If @a prio is non-zero, the new task moves to Xenomai's real-time
- * FIFO scheduling class, aka SCHED_RT. If @a prio is zero, the task
+ * FIFO scheduling class, aka SCHED_FIFO. If @a prio is zero, the task
  * moves to the regular SCHED_OTHER class.
  *
  * Running Xenomai tasks with zero priority is useful for running non
@@ -755,7 +755,7 @@ int rt_task_shadow(RT_TASK *task, const char *name, int 
prio, int mode)
        if (task)
                task->thread = self;
 
-       policy = prio ? SCHED_RT : SCHED_OTHER;
+       policy = prio ? SCHED_FIFO : SCHED_OTHER;
        param_ex.sched_priority = prio;
        ret = __bt(copperplate_renice_local_thread(self, policy, &param_ex));
 out:
diff --git a/lib/copperplate/regd/fs-common.c b/lib/copperplate/regd/fs-common.c
index eadf309..790e877 100644
--- a/lib/copperplate/regd/fs-common.c
+++ b/lib/copperplate/regd/fs-common.c
@@ -143,8 +143,8 @@ int open_threads(struct fsobj *fsobj, void *priv)
                format_time(p->timeout, tbuf, sizeof(tbuf));
                format_thread_status(p, sbuf, sizeof(sbuf));
                switch (p->policy) {
-               case SCHED_RT:
-                       sched_class = "rt";
+               case SCHED_FIFO:
+                       sched_class = "fifo";
                        break;
                case SCHED_RR:
                        sched_class = "rr";
diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 4515c9e..67328c1 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -202,7 +202,7 @@ static void start_agent(void)
        sigaddset(&set, SIGAGENT);
        pthread_sigmask(SIG_BLOCK, &set, NULL);
 
-       cta.policy = SCHED_RT;
+       cta.policy = SCHED_CORE;
        cta.param_ex.sched_priority = threadobj_agent_prio;
        cta.prologue = agent_prologue;
        cta.run = agent_loop;
@@ -496,7 +496,7 @@ static void unblock_sighandler(int sig)
 static void roundrobin_handler(int sig)
 {
        /*
-        * We do manual round-robin over SCHED_FIFO(RT) to allow for
+        * We do manual round-robin over SCHED_FIFO to allow for
         * multiple arbitrary time slices (i.e. vs the kernel
         * pre-defined and fixed one).
         */
@@ -537,7 +537,7 @@ static inline void pkg_init_corespec(void)
        /*
         * We don't have builtin scheduler-lock feature over Mercury,
         * so we emulate it by reserving the highest thread priority
-        * level from the SCHED_RT class to disable involuntary
+        * level from the SCHED_FIFO class to disable involuntary
         * preemption.
         *
         * NOTE: The remote agent thread will also run with the
@@ -1583,7 +1583,7 @@ static inline int main_overlay(void)
 
 int threadobj_pkg_init(void)
 {
-       threadobj_irq_prio = __RT(sched_get_priority_max(SCHED_RT));
+       threadobj_irq_prio = __RT(sched_get_priority_max(SCHED_CORE));
        threadobj_high_prio = threadobj_irq_prio - 1;
        threadobj_agent_prio = threadobj_high_prio;
 
diff --git a/lib/copperplate/timerobj.c b/lib/copperplate/timerobj.c
index f9938f1..7854689 100644
--- a/lib/copperplate/timerobj.c
+++ b/lib/copperplate/timerobj.c
@@ -157,7 +157,7 @@ static int timerobj_spawn_server(void)
        if (svthread)
                goto out;
 
-       cta.policy = SCHED_RT;
+       cta.policy = SCHED_CORE;
        cta.param_ex.sched_priority = threadobj_irq_prio;
        cta.prologue = server_prologue;
        cta.run = timerobj_server;
diff --git a/lib/psos/task.c b/lib/psos/task.c
index ac6f8ae..1eaf86b 100644
--- a/lib/psos/task.c
+++ b/lib/psos/task.c
@@ -214,21 +214,19 @@ static void *task_trampoline(void *arg)
 }
 
 /*
- * By default, pSOS priorities are mapped 1:1 to SCHED_RT
- * levels. SCHED_RT is SCHED_COBALT in dual kernel mode, or SCHED_FIFO
- * when running over the Mercury core. We allow up to 257 priority
- * levels over Cobalt when running in primary mode, 99 over the
- * regular glibc's POSIX interface.
+ * By default, pSOS priorities are mapped 1:1 to SCHED_FIFO
+ * levels. The available priority range is [1..256] over Cobalt when
+ * running in primary mode, and [1..99] over the regular kernel with
+ * the POSIX interface.
  *
- * NOTE: in dual kernel mode, a thread transitioning to secondary mode
- * has its priority ceiled to 99 in the SCHED_FIFO class.
+ * NOTE: over Cobalt, a thread transitioning to secondary mode has its
+ * priority ceiled to 99 in the regular POSIX SCHED_FIFO class.
  *
  * The application code may override the routine doing the priority
- * mapping from pSOS to SCHED_RT (normalize). The bottom line is that
- * normalized priorities should be in the range
- * [ 1 .. sched_get_priority_max(SCHED_RT) - 1 ] inclusive.
+ * mapping from pSOS to SCHED_FIFO (normalize). Normalized priorities
+ * returned by this routine must be in the range [ 1
+ * .. sched_get_priority_max(SCHED_FIFO) - 1 ] inclusive.
  */
-
 __attribute__ ((weak))
 int psos_task_normalize_priority(unsigned long psos_prio)
 {
@@ -237,20 +235,20 @@ int psos_task_normalize_priority(unsigned long psos_prio)
                      "priority levels to range [1..%d]",
                      threadobj_high_prio);
 
-       /* Map a pSOS priority level to a SCHED_RT one. */
+       /* Map a pSOS priority level to a SCHED_FIFO one. */
        return psos_prio;
 }
 
 /*
- * Although default pSOS priorities are mapped 1:1 to SCHED_RT,
- * we do still have to use a denormalize function because these
- * calls are weak and application code may be override the call
- * and implement the mapping differently.
+ * Although default pSOS priorities are mapped 1:1 to SCHED_FIFO, we
+ * do still have to use a denormalize function because these calls are
+ * weak and application code may be override the call and implement
+ * the mapping differently.
  */
 __attribute__ ((weak))
 unsigned long psos_task_denormalize_priority(int core_prio)
 {
-       /* Map a SCHED_RT priority level to a pSOS one. */
+       /* Map a SCHED_FIFO priority level to a pSOS one. */
        return core_prio;
 }
 
@@ -327,7 +325,7 @@ u_long t_create(const char *name, u_long prio,
 
        idata.magic = task_magic;
        idata.finalizer = task_finalizer;
-       idata.policy = cprio ? SCHED_RT : SCHED_OTHER;
+       idata.policy = cprio ? SCHED_FIFO : SCHED_OTHER;
        idata.param_ex.sched_priority = cprio;
        ret = threadobj_init(&task->thobj, &idata);
        if (ret)
@@ -461,7 +459,7 @@ u_long t_setpri(u_long tid, u_long newprio, u_long 
*oldprio_r)
                return ERR_SETPRI;
        }
 
-       policy = cprio ? SCHED_RT : SCHED_OTHER;
+       policy = cprio ? SCHED_FIFO : SCHED_OTHER;
        param_ex.sched_priority = cprio;
        ret = threadobj_set_schedparam(&task->thobj, policy, &param_ex);
        put_psos_task(task);
diff --git a/lib/vxworks/taskLib.c b/lib/vxworks/taskLib.c
index cf7ebde..cdb81b2 100644
--- a/lib/vxworks/taskLib.c
+++ b/lib/vxworks/taskLib.c
@@ -270,29 +270,26 @@ static void *task_trampoline(void *arg)
 }
 
 /*
- * By default, VxWorks priorities are mapped 1:1 to SCHED_RT
- * levels. SCHED_RT is SCHED_COBALT in dual kernel mode, or SCHED_FIFO
- * when running over the Mercury core. We allow up to 257 priority
- * levels over Cobalt when running in primary mode, 99 over the
- * regular glibc's POSIX interface.
+ * By default, WIND kernel priorities are reversely mapped to
+ * SCHED_FIFO levels. The available priority range is [1..256] over
+ * Cobalt when running in primary mode, and [1..99] over the regular
+ * kernel with the POSIX interface.
  *
- * NOTE: in dual kernel mode, a thread transitioning to secondary mode
- * has its priority ceiled to 99 in the SCHED_FIFO class.
+ * NOTE: over Cobalt, a thread transitioning to secondary mode has its
+ * priority ceiled to 99 in the regular POSIX SCHED_FIFO class.
  *
- * The application code may override the routines doing the priority
- * mappings from VxWorks to SCHED_RT (normalize) and conversely
- * (denormalize). The bottom line is that normalized priorities should
- * be in the range [ 1 .. sched_get_priority_max(SCHED_RT) - 1 ]
- * inclusive.
+ * The application code may override the routine doing the priority
+ * mapping from VxWorks to SCHED_FIFO (normalize). Normalized
+ * priorities returned by this routine must be in the range [ 1
+ * .. sched_get_priority_max(SCHED_FIFO) - 1 ] inclusive.
  */
-
 __attribute__ ((weak))
 int wind_task_normalize_priority(int wind_prio)
 {
        /*
-        * SCHED_RT priorities are always 1-based regardless of the
+        * SCHED_FIFO priorities are always 1-based regardless of the
         * underlying real-time core. We remap the lowest VxWorks
-        * priority to the lowest available level in the SCHED_RT
+        * priority to the lowest available level in the SCHED_FIFO
         * policy.
         */
        if (wind_prio > threadobj_high_prio - 1)
@@ -300,14 +297,14 @@ int wind_task_normalize_priority(int wind_prio)
                      "priority levels to range [%d..0]",
                      threadobj_high_prio - 1);
 
-       /* Map a VxWorks priority level to a SCHED_RT one. */
+       /* Map a VxWorks priority level to a SCHED_FIFO one. */
        return threadobj_high_prio - wind_prio - 1;
 }
 
 __attribute__ ((weak))
 int wind_task_denormalize_priority(int core_prio)
 {
-       /* Map a SCHED_RT priority level to a VxWorks one. */
+       /* Map a SCHED_FIFO priority level to a VxWorks one. */
        return threadobj_high_prio - core_prio - 1;
 }
 
@@ -353,7 +350,7 @@ static STATUS __taskInit(struct wind_task *task,
 
        idata.magic = task_magic;
        idata.finalizer = task_finalizer;
-       idata.policy = cprio ? SCHED_RT : SCHED_OTHER;
+       idata.policy = cprio ? SCHED_FIFO : SCHED_OTHER;
        idata.param_ex.sched_priority = cprio;
        ret = threadobj_init(&task->thobj, &idata);
        if (ret) {
@@ -749,7 +746,7 @@ STATUS taskPrioritySet(TASK_ID tid, int prio)
        }
 
        CANCEL_DEFER(svc);
-       policy = cprio ? SCHED_RT : SCHED_OTHER;
+       policy = cprio ? SCHED_FIFO : SCHED_OTHER;
        param_ex.sched_priority = cprio;
        ret = threadobj_set_schedparam(&task->thobj, policy, &param_ex);
        CANCEL_RESTORE(svc);


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

Reply via email to