Module: xenomai-head Branch: master Commit: c0bb8cbe4ac60c85f2fec1964cffc0f52b5a7473 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=c0bb8cbe4ac60c85f2fec1964cffc0f52b5a7473
Author: Philippe Gerum <r...@xenomai.org> Date: Sun Sep 20 11:38:46 2009 +0200 nucleus: fix scheduler class init w/ XENO_OPT_NUCLEUS=m --- include/asm-sim/bits/init.h | 10 +-------- include/nucleus/pod.h | 11 ++++++++++ include/nucleus/sched.h | 2 +- ksrc/nucleus/Makefile | 13 +++-------- ksrc/nucleus/module.c | 44 +++++++++++++++++----------------------- ksrc/nucleus/sched-idle.c | 7 ------ ksrc/nucleus/sched-rt.c | 7 ------ ksrc/nucleus/sched-sporadic.c | 7 ------ ksrc/nucleus/sched-tp.c | 7 ------ ksrc/nucleus/sched.c | 25 ++++++++++++++++------ 10 files changed, 54 insertions(+), 79 deletions(-) diff --git a/include/asm-sim/bits/init.h b/include/asm-sim/bits/init.h index 14682a5..77a05da 100644 --- a/include/asm-sim/bits/init.h +++ b/include/asm-sim/bits/init.h @@ -64,14 +64,6 @@ void mvm_root (void *cookie) __mvm_breakable(mvm_terminate)(0); } -static inline void __register_sched_classes(void) -{ - xnsched_register_class(&xnsched_class_idle); - xnsched_register_class(&xnsched_class_rt); - xnsched_register_class(&xnsched_class_sporadic); - xnsched_register_class(&xnsched_class_tp); -} - int main (int argc, char *argv[]) { xnarchtcb_t tcb; @@ -81,7 +73,7 @@ int main (int argc, char *argv[]) if (err) __mvm_breakable(mvm_fatal)("sys_init() failed, err=%x\n",err); - __register_sched_classes(); + xnsched_register_classes(); mvm_init(argc,argv); diff --git a/include/nucleus/pod.h b/include/nucleus/pod.h index ec577de..e652a1e 100644 --- a/include/nucleus/pod.h +++ b/include/nucleus/pod.h @@ -111,6 +111,17 @@ static inline void xnpod_init_proc(void) {} static inline void xnpod_cleanup_proc(void) {} #endif /* !CONFIG_PROC_FS */ +static inline void xnpod_mount(void) +{ + xnsched_register_classes(); + xnpod_init_proc(); +} + +static inline void xnpod_umount(void) +{ + xnpod_cleanup_proc(); +} + #ifdef __cplusplus extern "C" { #endif diff --git a/include/nucleus/sched.h b/include/nucleus/sched.h index 15dd42b..c96d65d 100644 --- a/include/nucleus/sched.h +++ b/include/nucleus/sched.h @@ -241,7 +241,7 @@ void xnsched_init_proc(void); void xnsched_cleanup_proc(void); -int xnsched_register_class(struct xnsched_class *sched_class); +void xnsched_register_classes(void); void xnsched_init(struct xnsched *sched, int cpu); diff --git a/ksrc/nucleus/Makefile b/ksrc/nucleus/Makefile index bc39f1e..ee8512c 100644 --- a/ksrc/nucleus/Makefile +++ b/ksrc/nucleus/Makefile @@ -6,12 +6,9 @@ obj-$(CONFIG_XENO_OPT_NUCLEUS) += xeno_nucleus.o xeno_nucleus-y := \ bufd.o heap.o intr.o pod.o registry.o \ - synch.o thread.o timebase.o timer.o sched.o + synch.o thread.o timebase.o timer.o sched.o \ + sched-idle.o sched-rt.o -# CAUTION: the declaration order of scheduling classes is -# significant. Lower priority classes shall be listed first. -xeno_nucleus-y += sched-idle.o -xeno_nucleus-y += sched-rt.o xeno_nucleus-$(CONFIG_XENO_OPT_SCHED_SPORADIC) += sched-sporadic.o xeno_nucleus-$(CONFIG_XENO_OPT_SCHED_TP) += sched-tp.o @@ -38,11 +35,9 @@ list-multi := xeno_nucleus.o xeno_nucleus-objs := \ bufd.o heap.o intr.o pod.o registry.o \ - synch.o thread.o timebase.o timer.o sched.o + synch.o thread.o timebase.o timer.o sched.o \ + sched-idle.o sched-rt.o -# CAUTION: the declaration order of scheduling classes is -# significant. Lower priority classes shall be listed first. -opt_objs-y := sched-idle.o sched-rt.o opt_objs-$(CONFIG_XENO_OPT_SCHED_SPORADIC) += sched-sporadic.o opt_objs-$(CONFIG_XENO_OPT_SCHED_TP) += sched-tp.o diff --git a/ksrc/nucleus/module.c b/ksrc/nucleus/module.c index de56dec..141276a 100644 --- a/ksrc/nucleus/module.c +++ b/ksrc/nucleus/module.c @@ -83,50 +83,45 @@ EXPORT_SYMBOL_GPL(xnmod_alloc_glinks); int __init __xeno_sys_init(void) { - int err; + int ret; xnmod_sysheap_size = module_param_value(sysheap_size_arg) * 1024; nkmsgbuf = xnarch_alloc_host_mem(XNPOD_FATAL_BUFSZ); if (nkmsgbuf == NULL) { - err = -ENOMEM; + ret = -ENOMEM; goto fail; } - err = xnarch_init(); - - if (err) + ret = xnarch_init(); + if (ret) goto fail; #ifndef __XENO_SIM__ - err = xnheap_init_mapped(&__xnsys_global_ppd.sem_heap, + ret = xnheap_init_mapped(&__xnsys_global_ppd.sem_heap, CONFIG_XENO_OPT_GLOBAL_SEM_HEAPSZ * 1024, XNARCH_SHARED_HEAP_FLAGS); - if (err) + if (ret) goto cleanup_arch; #endif #ifdef __KERNEL__ - xnpod_init_proc(); - + xnpod_mount(); xnintr_mount(); #ifdef CONFIG_XENO_OPT_PIPE - err = xnpipe_mount(); - - if (err) + ret = xnpipe_mount(); + if (ret) goto cleanup_proc; #endif /* CONFIG_XENO_OPT_PIPE */ #ifdef CONFIG_XENO_OPT_PERVASIVE - err = xnshadow_mount(); - - if (err) + ret = xnshadow_mount(); + if (ret) goto cleanup_pipe; - err = xnheap_mount(); - - if (err) + ret = xnheap_mount(); + if (ret) goto cleanup_shadow; #endif /* CONFIG_XENO_OPT_PERVASIVE */ #endif /* __KERNEL__ */ @@ -167,7 +162,7 @@ int __init __xeno_sys_init(void) #endif /* CONFIG_XENO_OPT_PIPE */ - xnpod_cleanup_proc(); + xnpod_umount(); cleanup_arch: @@ -177,11 +172,11 @@ int __init __xeno_sys_init(void) fail: - xnlogerr("system init failed, code %d.\n", err); + xnlogerr("system init failed, code %d.\n", ret); - xeno_nucleus_status = err; + xeno_nucleus_status = ret; - return err; + return ret; } void __exit __xeno_sys_exit(void) @@ -189,13 +184,12 @@ void __exit __xeno_sys_exit(void) xnpod_shutdown(XNPOD_NORMAL_EXIT); #ifdef CONFIG_XENO_OPT_PERVASIVE - /* Must take place before xnpod_cleanup_proc. */ + /* Must take place before xnpod_umount(). */ xnshadow_cleanup(); #endif /* CONFIG_XENO_OPT_PERVASIVE */ xntbase_umount(); - - xnpod_cleanup_proc(); + xnpod_umount(); xnarch_exit(); diff --git a/ksrc/nucleus/sched-idle.c b/ksrc/nucleus/sched-idle.c index de25da0..39faa6a 100644 --- a/ksrc/nucleus/sched-idle.c +++ b/ksrc/nucleus/sched-idle.c @@ -64,10 +64,3 @@ struct xnsched_class xnsched_class_idle = { .weight = XNSCHED_CLASS_WEIGHT(0), .name = "idle" }; - -static int __init register_sched_class(void) -{ - return xnsched_register_class(&xnsched_class_idle); -} - -__initcall(register_sched_class); diff --git a/ksrc/nucleus/sched-rt.c b/ksrc/nucleus/sched-rt.c index dc23163..7483166 100644 --- a/ksrc/nucleus/sched-rt.c +++ b/ksrc/nucleus/sched-rt.c @@ -363,10 +363,3 @@ struct xnsched_class xnsched_class_rt = { .name = "rt" }; EXPORT_SYMBOL_GPL(xnsched_class_rt); - -static int __init register_sched_class(void) -{ - return xnsched_register_class(&xnsched_class_rt); -} - -__initcall(register_sched_class); diff --git a/ksrc/nucleus/sched-sporadic.c b/ksrc/nucleus/sched-sporadic.c index 57fc357..0ea14e0 100644 --- a/ksrc/nucleus/sched-sporadic.c +++ b/ksrc/nucleus/sched-sporadic.c @@ -630,10 +630,3 @@ struct xnsched_class xnsched_class_sporadic = { .name = "pss" }; EXPORT_SYMBOL_GPL(xnsched_class_sporadic); - -static int __init register_sched_class(void) -{ - return xnsched_register_class(&xnsched_class_sporadic); -} - -__initcall(register_sched_class); diff --git a/ksrc/nucleus/sched-tp.c b/ksrc/nucleus/sched-tp.c index 3d40c76..a08b360 100644 --- a/ksrc/nucleus/sched-tp.c +++ b/ksrc/nucleus/sched-tp.c @@ -466,10 +466,3 @@ struct xnsched_class xnsched_class_tp = { .name = "tp" }; EXPORT_SYMBOL_GPL(xnsched_class_tp); - -static int __init register_sched_class(void) -{ - return xnsched_register_class(&xnsched_class_tp); -} - -__initcall(register_sched_class); diff --git a/ksrc/nucleus/sched.c b/ksrc/nucleus/sched.c index c12b759..33b0713 100644 --- a/ksrc/nucleus/sched.c +++ b/ksrc/nucleus/sched.c @@ -33,20 +33,31 @@ static struct xnsched_class *xnsched_class_highest; #define for_each_xnsched_class(p) \ for (p = xnsched_class_highest; p; p = p->next) -int xnsched_register_class(struct xnsched_class *sched_class) +static void xnsched_register_class(struct xnsched_class *sched_class) { - /* - * The build rules shall ensure that scheduling classes are - * registered by increasing priority order via initcalls, so - * that the highest priority class is always registered last. - */ sched_class->next = xnsched_class_highest; xnsched_class_highest = sched_class; + + /* + * Classes shall be registered by increasing priority order, + * idle first and up. + */ XENO_BUGON(NUCLEUS, sched_class->next && sched_class->next->weight > sched_class->weight); + xnloginfo("scheduling class %s registered.\n", sched_class->name); +} - return 0; +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_WATCHDOG _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git