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

Author: Kim De Mey <kim.de...@gmail.com>
Date:   Mon Nov 25 12:18:00 2013 +0100

psos: denormalize previous priority value returned by t_setpri()

Add the psos_task_denormalize_priority() and psos_task_get_priority()
functions. Use psos_task_get_priority() to fill oldprio_r in t_setpri().

Signed-off-by: Kim De Mey <kim.de...@gmail.com>

---

 include/psos/psos.h |    1 +
 lib/psos/task.c     |   23 ++++++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/include/psos/psos.h b/include/psos/psos.h
index 4817035..38bc45f 100644
--- a/include/psos/psos.h
+++ b/include/psos/psos.h
@@ -366,6 +366,7 @@ u_long tm_wkwhen(u_long date,
                 u_long ticks);
 
 int psos_task_normalize_priority(unsigned long psos_prio);
+int psos_task_denormalize_priority(unsigned long core_prio);
 
 extern unsigned int psos_long_names;
 
diff --git a/lib/psos/task.c b/lib/psos/task.c
index 6715a9f..ac07b47 100644
--- a/lib/psos/task.c
+++ b/lib/psos/task.c
@@ -236,6 +236,21 @@ int psos_task_normalize_priority(unsigned long psos_prio)
        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.
+ */
+
+__attribute__ ((weak))
+int psos_task_denormalize_priority(unsigned long core_prio)
+{
+       /* Map a SCHED_RT priority level to a pSOS one. */
+       return core_prio;
+}
+
+
 static int check_task_priority(u_long psos_prio, int *core_prio)
 {
        if (psos_prio < 1 || psos_prio > 255) /* In theory. */
@@ -246,6 +261,12 @@ static int check_task_priority(u_long psos_prio, int 
*core_prio)
        return SUCCESS;
 }
 
+static int psos_task_get_priority(struct psos_task *task)
+{
+       int prio = threadobj_get_priority(&task->thobj);
+       return psos_task_denormalize_priority(prio);
+}
+
 u_long t_create(const char *name, u_long prio,
                u_long sstack, u_long ustack, u_long flags, u_long *tid_r)
 {
@@ -416,7 +437,7 @@ u_long t_setpri(u_long tid, u_long newprio, u_long 
*oldprio_r)
        if (task == NULL)
                return ret;
 
-       *oldprio_r = threadobj_get_priority(&task->thobj);
+       *oldprio_r = psos_task_get_priority(task);
 
        if (newprio == 0) { /* Only inquires for the task priority. */
                put_psos_task(task);


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

Reply via email to