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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Dec 21 16:00:08 2013 +0100

cobalt/sched: always check policy settings

---

 include/cobalt/kernel/sched.h |   17 +++++++++++++++++
 kernel/cobalt/sched.c         |   11 +++--------
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index 065408f..870de29 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -538,6 +538,23 @@ static inline void xnsched_tick(struct xnsched *sched)
                sched_class->sched_tick(sched);
 }
 
+static inline int xnsched_declare(struct xnsched_class *sched_class,
+                                 struct xnthread *thread,
+                                 const union xnsched_policy_param *p)
+{
+       int ret;
+
+       if (sched_class->sched_declare) {
+               ret = sched_class->sched_declare(thread, p);
+               if (ret)
+                       return ret;
+       }
+       if (sched_class != thread->base_class)
+               sched_class->nthreads++;
+
+       return 0;
+}
+
 #ifdef CONFIG_XENO_OPT_SCHED_CLASSES
 
 static inline void xnsched_enqueue(struct xnthread *thread)
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index e8c012e..ffd50be 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -376,14 +376,9 @@ int xnsched_set_policy(struct xnthread *thread,
         * affect the previous class (such as touching thread->rlink
         * for instance).
         */
-       if (sched_class != thread->base_class) {
-               if (sched_class->sched_declare) {
-                       ret = sched_class->sched_declare(thread, p);
-                       if (ret)
-                               return ret;
-               }
-               sched_class->nthreads++;
-       }
+       ret = xnsched_declare(sched_class, thread, p);
+       if (ret)
+               return ret;
 
        /*
         * As a special case, we may be called from __xnthread_init()


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

Reply via email to