Module: xenomai-3 Branch: master Commit: 880b3acbd876a65f8fbe8c27b09762b06c06e846 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=880b3acbd876a65f8fbe8c27b09762b06c06e846
Author: Philippe Gerum <r...@xenomai.org> Date: Sun Jul 26 12:37:15 2015 +0200 copperplate/registry: force SCHED_OTHER on helper threads We might inherit SCHED_FIFO from the parent thread creating the registry threads if --main-prio was given for starting the application program. Make sure to switch to SCHED_OTHER for serving registry requests. --- lib/copperplate/regd/regd.c | 7 ++++++- lib/copperplate/registry.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/copperplate/regd/regd.c b/lib/copperplate/regd/regd.c index bcf5a9d..4f48273 100644 --- a/lib/copperplate/regd/regd.c +++ b/lib/copperplate/regd/regd.c @@ -471,7 +471,7 @@ bootstrap: ret = bootstrap_core(); if (ret) - error(1, -ret, "cannot bootstap core interface"); + error(1, -ret, "cannot bootstrap core interface"); __copperplate_setup_data.session_label = session; __copperplate_setup_data.registry_root = rootdir; @@ -501,6 +501,7 @@ bootstrap: int main(int argc, char *const *argv) { int lindex, opt, ret, flags = 0; + struct sched_param schedp; struct sigaction sa; for (;;) { @@ -533,6 +534,10 @@ int main(int argc, char *const *argv) if (rootdir == NULL) error(1, EINVAL, "--root must be given"); + /* Force SCHED_OTHER. */ + schedp.sched_priority = 0; + pthread_setschedparam(pthread_self(), SCHED_OTHER, &schedp); + memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; sigaction(SIGCHLD, &sa, NULL); diff --git a/lib/copperplate/registry.c b/lib/copperplate/registry.c index adf0d73..c379f15 100644 --- a/lib/copperplate/registry.c +++ b/lib/copperplate/registry.c @@ -751,6 +751,7 @@ int __registry_pkg_init(const char *arg0, char *mountpt, int flags) { struct regfs_data *p = regfs_get_context(); pthread_mutexattr_t mattr; + struct sched_param schedp; pthread_attr_t thattr; int ret; @@ -768,8 +769,12 @@ int __registry_pkg_init(const char *arg0, char *mountpt, int flags) registry_add_dir("/"); /* Create the fs root. */ - /* We want a SCHED_OTHER thread, use defaults. */ + /* We want a SCHED_OTHER thread. */ pthread_attr_init(&thattr); + pthread_attr_setinheritsched(&thattr, PTHREAD_EXPLICIT_SCHED); + pthread_attr_setschedpolicy(&thattr, SCHED_OTHER); + schedp.sched_priority = 0; + pthread_attr_setschedparam(&thattr, &schedp); /* * Memory is locked as the process data grows, so we set a * smaller stack size for the fs thread than the default 8mb _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://xenomai.org/mailman/listinfo/xenomai-git