Module: xenomai-3 Branch: next Commit: f15920c67d075cee304e673ad2b76610dda3b97d URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=f15920c67d075cee304e673ad2b76610dda3b97d
Author: Philippe Gerum <r...@xenomai.org> Date: Wed Oct 29 10:03:46 2014 +0100 cobalt/sched: assoc policy identifier to sched class --- include/cobalt/kernel/sched.h | 1 + kernel/cobalt/posix/thread.c | 10 ++++------ kernel/cobalt/posix/thread.h | 3 --- kernel/cobalt/sched-idle.c | 1 + kernel/cobalt/sched-quota.c | 2 ++ kernel/cobalt/sched-rt.c | 1 + kernel/cobalt/sched-sporadic.c | 2 ++ kernel/cobalt/sched-tp.c | 2 ++ kernel/cobalt/sched-weak.c | 2 ++ 9 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h index 424538b..1ee2aa7 100644 --- a/include/cobalt/kernel/sched.h +++ b/include/cobalt/kernel/sched.h @@ -158,6 +158,7 @@ struct xnsched_class { int nthreads; struct xnsched_class *next; int weight; + int policy; const char *name; }; diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c index 27c824b..0786ad3 100644 --- a/kernel/cobalt/posix/thread.c +++ b/kernel/cobalt/posix/thread.c @@ -264,7 +264,6 @@ pthread_setschedparam_ex(struct cobalt_thread *thread, ret = -EINVAL; goto out; } - thread->sched_u_policy = policy; xnthread_set_slice(&thread->threadbase, tslice); if (cobalt_call_extension(thread_setsched, &thread->extref, ret, sched_class, ¶m) && ret) @@ -284,7 +283,6 @@ pthread_getschedparam_ex(struct cobalt_thread *thread, { struct xnsched_class *base_class; struct xnthread *base_thread; - int prio; spl_t s; xnlock_get_irqsave(&nklock, s); @@ -297,9 +295,10 @@ pthread_getschedparam_ex(struct cobalt_thread *thread, base_thread = &thread->threadbase; base_class = base_thread->base_class; - *policy_r = thread->sched_u_policy; - prio = xnthread_base_priority(base_thread); - param_ex->sched_priority = prio; + param_ex->sched_priority = xnthread_base_priority(base_thread); + *policy_r = base_class->policy; + if (param_ex->sched_priority == 0) /* SCHED_FIFO/SCHED_WEAK */ + *policy_r = SCHED_NORMAL; if (base_class == &xnsched_class_rt) { if (xnthread_test_state(base_thread, XNRRB)) @@ -379,7 +378,6 @@ static inline int pthread_create(struct cobalt_thread **thread_p, return ret; } - thread->sched_u_policy = policy; thread->magic = COBALT_THREAD_MAGIC; xnsynch_init(&thread->monitor_synch, XNSYNCH_FIFO, NULL); diff --git a/kernel/cobalt/posix/thread.h b/kernel/cobalt/posix/thread.h index d1bc034..34dc6cc 100644 --- a/kernel/cobalt/posix/thread.h +++ b/kernel/cobalt/posix/thread.h @@ -102,9 +102,6 @@ struct cobalt_thread { struct xnsynch sigwait; struct list_head signext; - /** Cached value for current policy (user side). */ - int sched_u_policy; - /** Monitor wait object and link holder. */ struct xnsynch monitor_synch; struct list_head monitor_link; diff --git a/kernel/cobalt/sched-idle.c b/kernel/cobalt/sched-idle.c index 5127798..8f59c0d 100644 --- a/kernel/cobalt/sched-idle.c +++ b/kernel/cobalt/sched-idle.c @@ -56,5 +56,6 @@ struct xnsched_class xnsched_class_idle = { .sched_getparam = xnsched_idle_getparam, .sched_trackprio = xnsched_idle_trackprio, .weight = XNSCHED_CLASS_WEIGHT(0), + .policy = SCHED_IDLE, .name = "idle" }; diff --git a/kernel/cobalt/sched-quota.c b/kernel/cobalt/sched-quota.c index 8a72819..71e2c36 100644 --- a/kernel/cobalt/sched-quota.c +++ b/kernel/cobalt/sched-quota.c @@ -19,6 +19,7 @@ #include <linux/bitmap.h> #include <cobalt/kernel/sched.h> #include <cobalt/kernel/arith.h> +#include <cobalt/uapi/sched.h> /* * With this policy, each per-CPU scheduler slot maintains a list of @@ -765,6 +766,7 @@ struct xnsched_class xnsched_class_quota = { .sched_cleanup_vfile = xnsched_quota_cleanup_vfile, #endif .weight = XNSCHED_CLASS_WEIGHT(3), + .policy = SCHED_QUOTA, .name = "quota" }; EXPORT_SYMBOL_GPL(xnsched_class_quota); diff --git a/kernel/cobalt/sched-rt.c b/kernel/cobalt/sched-rt.c index 44f90dd..3bd9308 100644 --- a/kernel/cobalt/sched-rt.c +++ b/kernel/cobalt/sched-rt.c @@ -246,6 +246,7 @@ struct xnsched_class xnsched_class_rt = { .sched_cleanup_vfile = xnsched_rt_cleanup_vfile, #endif .weight = XNSCHED_CLASS_WEIGHT(4), + .policy = SCHED_FIFO, .name = "rt" }; EXPORT_SYMBOL_GPL(xnsched_class_rt); diff --git a/kernel/cobalt/sched-sporadic.c b/kernel/cobalt/sched-sporadic.c index 77f1822..f1a602a 100644 --- a/kernel/cobalt/sched-sporadic.c +++ b/kernel/cobalt/sched-sporadic.c @@ -18,6 +18,7 @@ */ #include <cobalt/kernel/sched.h> #include <cobalt/kernel/heap.h> +#include <cobalt/uapi/sched.h> #define MAX_REPLENISH CONFIG_XENO_OPT_SCHED_SPORADIC_MAXREPL @@ -537,6 +538,7 @@ struct xnsched_class xnsched_class_sporadic = { .sched_cleanup_vfile = xnsched_sporadic_cleanup_vfile, #endif .weight = XNSCHED_CLASS_WEIGHT(3), + .policy = SCHED_SPORADIC, .name = "pss" }; EXPORT_SYMBOL_GPL(xnsched_class_sporadic); diff --git a/kernel/cobalt/sched-tp.c b/kernel/cobalt/sched-tp.c index 7ce04c1..774c3b7 100644 --- a/kernel/cobalt/sched-tp.c +++ b/kernel/cobalt/sched-tp.c @@ -18,6 +18,7 @@ */ #include <cobalt/kernel/sched.h> #include <cobalt/kernel/heap.h> +#include <cobalt/uapi/sched.h> static void tp_schedule_next(struct xnsched_tp *tp) { @@ -431,6 +432,7 @@ struct xnsched_class xnsched_class_tp = { .sched_cleanup_vfile = xnsched_tp_cleanup_vfile, #endif .weight = XNSCHED_CLASS_WEIGHT(2), + .policy = SCHED_TP, .name = "tp" }; EXPORT_SYMBOL_GPL(xnsched_class_tp); diff --git a/kernel/cobalt/sched-weak.c b/kernel/cobalt/sched-weak.c index 5ea32d8..64218d1 100644 --- a/kernel/cobalt/sched-weak.c +++ b/kernel/cobalt/sched-weak.c @@ -17,6 +17,7 @@ * 02111-1307, USA. */ #include <cobalt/kernel/sched.h> +#include <cobalt/uapi/sched.h> static void xnsched_weak_init(struct xnsched *sched) { @@ -207,6 +208,7 @@ struct xnsched_class xnsched_class_weak = { .sched_cleanup_vfile = xnsched_weak_cleanup_vfile, #endif .weight = XNSCHED_CLASS_WEIGHT(1), + .policy = SCHED_WEAK, .name = "weak" }; EXPORT_SYMBOL_GPL(xnsched_class_weak); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git