Module: xenomai-forge Branch: master Commit: a40251687c62a7d235b3ceaed69cac9066bedd52 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=a40251687c62a7d235b3ceaed69cac9066bedd52
Author: Philippe Gerum <r...@xenomai.org> Date: Mon Apr 23 15:27:05 2012 +0200 nucleus/sched: update scheduling class weights This patch changes the respective weights of scheduling classes, in order to give higher priority to classes whose threads are not throttled by any sort of mechanism, over classes limiting the execution time of their threads. This gives us (in ascending priority order): IDLE => TP => PSS => RT The net effect is that runnable RT threads will always be picked by the scheduler core before threads from other classes, which may be throttled by some class-specific mechanism. --- include/cobalt/nucleus/sched-rt.h | 7 ++++--- include/cobalt/nucleus/sched.h | 4 ++-- kernel/cobalt/nucleus/sched-rt.c | 2 +- kernel/cobalt/nucleus/sched-sporadic.c | 2 +- kernel/cobalt/nucleus/sched-tp.c | 8 +++----- kernel/cobalt/nucleus/sched.c | 8 ++++---- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/cobalt/nucleus/sched-rt.h b/include/cobalt/nucleus/sched-rt.h index bd40743..b411ea8 100644 --- a/include/cobalt/nucleus/sched-rt.h +++ b/include/cobalt/nucleus/sched-rt.h @@ -44,9 +44,10 @@ #ifdef __KERNEL__ -#if defined(CONFIG_XENO_OPT_SCALABLE_SCHED) && \ - XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS -#error "RT class cannot use multi-level queue (too many priority levels)" +#if XNSCHED_RT_NR_PRIO > XNSCHED_CLASS_MAX_PRIO || \ + (defined(CONFIG_XENO_OPT_SCALABLE_SCHED) && \ + XNSCHED_RT_NR_PRIO > XNSCHED_MLQ_LEVELS) +#error "RT class has too many priority levels" #endif extern struct xnsched_class xnsched_class_rt; diff --git a/include/cobalt/nucleus/sched.h b/include/cobalt/nucleus/sched.h index 24d6cd0..6fbc8d2 100644 --- a/include/cobalt/nucleus/sched.h +++ b/include/cobalt/nucleus/sched.h @@ -133,8 +133,8 @@ struct xnsched_class { const char *name; }; -#define XNSCHED_CLASS_MAX_THREADS 32768 -#define XNSCHED_CLASS_WEIGHT(n) (n * XNSCHED_CLASS_MAX_THREADS) +#define XNSCHED_CLASS_MAX_PRIO 1024 +#define XNSCHED_CLASS_WEIGHT(n) (n * XNSCHED_CLASS_MAX_PRIO) /* Placeholder for current thread priority */ #define XNSCHED_RUNPRIO 0x80000000 diff --git a/kernel/cobalt/nucleus/sched-rt.c b/kernel/cobalt/nucleus/sched-rt.c index bbd5319..c8919a7 100644 --- a/kernel/cobalt/nucleus/sched-rt.c +++ b/kernel/cobalt/nucleus/sched-rt.c @@ -253,7 +253,7 @@ struct xnsched_class xnsched_class_rt = { .sched_init_vfile = xnsched_rt_init_vfile, .sched_cleanup_vfile = xnsched_rt_cleanup_vfile, #endif - .weight = XNSCHED_CLASS_WEIGHT(1), + .weight = XNSCHED_CLASS_WEIGHT(3), .name = "rt" }; EXPORT_SYMBOL_GPL(xnsched_class_rt); diff --git a/kernel/cobalt/nucleus/sched-sporadic.c b/kernel/cobalt/nucleus/sched-sporadic.c index 73f6023..4d545f3 100644 --- a/kernel/cobalt/nucleus/sched-sporadic.c +++ b/kernel/cobalt/nucleus/sched-sporadic.c @@ -533,7 +533,7 @@ struct xnsched_class xnsched_class_sporadic = { .sched_init_vfile = xnsched_sporadic_init_vfile, .sched_cleanup_vfile = xnsched_sporadic_cleanup_vfile, #endif - .weight = XNSCHED_CLASS_WEIGHT(1), + .weight = XNSCHED_CLASS_WEIGHT(2), .name = "pss" }; EXPORT_SYMBOL_GPL(xnsched_class_sporadic); diff --git a/kernel/cobalt/nucleus/sched-tp.c b/kernel/cobalt/nucleus/sched-tp.c index 42688db..bc937d3 100644 --- a/kernel/cobalt/nucleus/sched-tp.c +++ b/kernel/cobalt/nucleus/sched-tp.c @@ -79,8 +79,7 @@ static void xnsched_tp_init(struct xnsched *sched) /* * Build the runqueues. Thread priorities for the TP policy - * are the same as RT priorities. TP is actually a superset of - * RT. + * are valid RT priorities. TP is actually a subset of RT. */ for (n = 0; n < CONFIG_XENO_OPT_SCHED_TP_NRPART; n++) sched_initpq(&tp->partitions[n].runnable, @@ -200,7 +199,7 @@ static void xnsched_tp_migrate(struct xnthread *thread, struct xnsched *sched) /* * Since our partition schedule is a per-scheduler property, * it cannot apply to a thread that moves to another CPU - * anymore. So we downgrade that thread to the RT class when a + * anymore. So we upgrade that thread to the RT class when a * CPU migration occurs. A subsequent call to * xnsched_set_policy() may move it back to TP scheduling, * with a partition assignment that fits the remote CPU's @@ -278,7 +277,6 @@ struct vfile_sched_tp_priv { struct xnholder *curr; }; - struct vfile_sched_tp_data { int cpu; pid_t pid; @@ -395,7 +393,7 @@ struct xnsched_class xnsched_class_tp = { .sched_init_vfile = xnsched_tp_init_vfile, .sched_cleanup_vfile = xnsched_tp_cleanup_vfile, #endif - .weight = XNSCHED_CLASS_WEIGHT(2), + .weight = XNSCHED_CLASS_WEIGHT(1), .name = "tp" }; EXPORT_SYMBOL_GPL(xnsched_class_tp); diff --git a/kernel/cobalt/nucleus/sched.c b/kernel/cobalt/nucleus/sched.c index d25bff0..43250bb 100644 --- a/kernel/cobalt/nucleus/sched.c +++ b/kernel/cobalt/nucleus/sched.c @@ -51,13 +51,13 @@ static void xnsched_register_class(struct xnsched_class *sched_class) void xnsched_register_classes(void) { xnsched_register_class(&xnsched_class_idle); - xnsched_register_class(&xnsched_class_rt); -#ifdef CONFIG_XENO_OPT_SCHED_SPORADIC - xnsched_register_class(&xnsched_class_sporadic); -#endif #ifdef CONFIG_XENO_OPT_SCHED_TP xnsched_register_class(&xnsched_class_tp); #endif +#ifdef CONFIG_XENO_OPT_SCHED_SPORADIC + xnsched_register_class(&xnsched_class_sporadic); +#endif + xnsched_register_class(&xnsched_class_rt); } #ifdef CONFIG_XENO_OPT_WATCHDOG _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git