Module: xenomai-3
Branch: next
Commit: 6960e2315191701914c5a7826076b2fb028ada04
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=6960e2315191701914c5a7826076b2fb028ada04

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Mar 20 17:58:33 2016 +0100

lib/cobalt: add config switch to enable lazy setsched update mode

--enable-lazy-setsched should be given for enabling lazy propagation
of scheduling parameters upon calls to pthread_setschedparam*(),
sched_setscheduler(). Defaults to off.

---

 configure.ac          |   19 +++++++++++++++++++
 lib/cobalt/internal.h |   12 ++++++++++++
 lib/cobalt/sched.c    |    2 +-
 lib/cobalt/thread.c   |    3 ++-
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 15c7499..5bcd7f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -284,6 +284,25 @@ if test x$workaround_condvar_pi = xy; then
    fi
 fi
 
+dnl Lazy schedparam propagation for Cobalt (default: off)
+
+unset lazy_setsched_update
+AC_MSG_CHECKING(whether to enable lazy scheduling parameter update)
+AC_ARG_ENABLE(lazy-setsched,
+       AS_HELP_STRING([--enable-lazy-setsched], [Enable lazy scheduling 
parameter update]),
+       [case "$enableval" in
+       y | yes) lazy_setsched_update=y ;;
+       *) unset lazy_setsched_update ;;
+       esac])
+AC_MSG_RESULT(${lazy_setsched_update:-no})
+if test x$lazy_setsched_update = xy; then
+   if test x$rtcore_type = xcobalt; then
+       AC_DEFINE(CONFIG_XENO_LAZY_SETSCHED,1,[config])
+   else
+        AC_MSG_WARN([No lazy scheduling parameter updates over Mercury - 
ignoring])
+   fi
+fi
+
 dnl Enable shared multi-processing (default: off)
 
 use_pshared=
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index 4b8252b..1531901 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -32,6 +32,18 @@ static inline int cobalt_is_relaxed(void)
        return cobalt_get_current_mode() & XNRELAX;
 }
 
+#ifdef CONFIG_XENO_LAZY_SETSCHED
+static inline int cobalt_eager_setsched(void)
+{
+       return cobalt_is_relaxed();
+}
+#else
+static inline int cobalt_eager_setsched(void)
+{
+       return 1;
+}
+#endif
+
 static inline
 struct cobalt_mutex_state *mutex_get_state(struct cobalt_mutex_shadow *shadow)
 {
diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c
index 87b9235..94f3323 100644
--- a/lib/cobalt/sched.c
+++ b/lib/cobalt/sched.c
@@ -297,7 +297,7 @@ int sched_setscheduler_ex(pid_t pid,
 
        /* See pthread_setschedparam_ex(). */
 
-       if (cobalt_is_relaxed()) {
+       if (cobalt_eager_setsched()) {
                std_policy = cobalt_xlate_schedparam(policy, param_ex, 
&std_param);
                ret = __STD(sched_setscheduler(pid, std_policy, &std_param));
                if (ret)
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 8b4568d..908516f 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -629,7 +629,8 @@ int pthread_setschedparam_ex(pthread_t thread,
         * threads should refrain from mixing APIs for managing
         * scheduling parameters, and only rely on libcobalt for this.
         */
-       if (cobalt_is_relaxed()) { /* True if shadow not mapped yet. */
+       if (cobalt_eager_setsched()) {
+               /* True if disabled or shadow not mapped yet. */
                std_policy = cobalt_xlate_schedparam(policy, param_ex, 
&std_param);
                ret = __STD(pthread_setschedparam(thread, std_policy, 
&std_param));
                if (ret)


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

Reply via email to