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

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

copperplate/threadobj: set global priority to weighted value over Cobalt

This fixes a long-standing issue with Cobalt-based systems, by having
threads wait on syncobj resources by priority values weighted by the
core priority of the scheduling class they belong to.

e.g. SCHED_FIFO,99 has higher priority than SCHED_QUOTA,99, and
obviously even higher than SCHED_WEAK,99.

---

 lib/copperplate/threadobj.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/lib/copperplate/threadobj.c b/lib/copperplate/threadobj.c
index 67328c1..ba0e4a3 100644
--- a/lib/copperplate/threadobj.c
+++ b/lib/copperplate/threadobj.c
@@ -420,6 +420,17 @@ int threadobj_set_mode(int clrmask, int setmask, int 
*mode_r) /* current->lock h
        return 0;
 }
 
+static inline int map_priority_corespec(int policy,
+                                       const struct sched_param_ex *param_ex)
+{
+       int prio;
+
+       prio = cobalt_sched_weighted_prio(policy, param_ex);
+       assert(prio >= 0);
+
+       return prio;
+}
+
 static inline int prepare_rr_corespec(struct threadobj *thobj, int policy,
                                      const struct sched_param_ex *param_ex) /* 
thobj->lock held */
 {
@@ -786,6 +797,12 @@ int threadobj_set_mode(int clrmask, int setmask, int 
*mode_r) /* current->lock h
        return __bt(ret);
 }
 
+static inline int map_priority_corespec(int policy,
+                                       const struct sched_param_ex *param_ex)
+{
+       return param_ex->sched_priority;
+}
+
 static inline int prepare_rr_corespec(struct threadobj *thobj, int policy,
                                      const struct sched_param_ex *param_ex) /* 
thobj->lock held */
 {
@@ -997,7 +1014,7 @@ static void set_global_priority(struct threadobj *thobj, 
int policy,
 {
        thobj->schedparam = *param_ex;
        thobj->policy = policy;
-       thobj->global_priority = param_ex->sched_priority;
+       thobj->global_priority = map_priority_corespec(policy, param_ex);
 }
 
 int threadobj_init(struct threadobj *thobj,


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

Reply via email to