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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Tue Mar  8 14:46:59 2016 +0100

lib/cobalt: Wrap pthread_setschedprio for proper real-time support

Implement pthread_setschedprio on top of pthread_setschedparam_ex with
the help of the new __SCHED_CURRENT policy. This ensures that prio
changes are directly applied to the real-time core, and that with just
a single syscall.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/cobalt/pthread.h   |    2 ++
 lib/cobalt/cobalt.wrappers |    1 +
 lib/cobalt/thread.c        |    9 +++++++++
 lib/cobalt/wrappers.c      |    6 ++++++
 4 files changed, 18 insertions(+)

diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h
index f1b1c8a..3e9bd47 100644
--- a/include/cobalt/pthread.h
+++ b/include/cobalt/pthread.h
@@ -53,6 +53,8 @@ COBALT_DECL(int, pthread_setschedparam(pthread_t thread,
                                       int policy,
                                       const struct sched_param *param));
 
+COBALT_DECL(int, pthread_setschedprio(pthread_t thread, int prio));
+
 COBALT_DECL(int, pthread_mutex_init(pthread_mutex_t *mutex,
                                    const pthread_mutexattr_t *attr));
 
diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers
index 75f29d6..19153ae 100644
--- a/lib/cobalt/cobalt.wrappers
+++ b/lib/cobalt/cobalt.wrappers
@@ -2,6 +2,7 @@
 --wrap pthread_create
 --wrap pthread_setschedparam
 --wrap pthread_getschedparam
+--wrap pthread_setschedprio
 --wrap pthread_yield
 --wrap sched_yield
 --wrap sched_get_priority_min
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index 908516f..62ca0a0 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -650,6 +650,15 @@ int pthread_setschedparam_ex(pthread_t thread,
        return ret;
 }
 
+COBALT_IMPL(int, pthread_setschedprio, (pthread_t thread, int prio))
+{
+       struct sched_param_ex param_ex = {
+               .sched_priority = prio,
+       };
+
+       return pthread_setschedparam_ex(thread, __SCHED_CURRENT, &param_ex);
+}
+
 /**
  * Get the scheduling policy and parameters of the specified thread.
  *
diff --git a/lib/cobalt/wrappers.c b/lib/cobalt/wrappers.c
index 09c74e5..1f1664e 100644
--- a/lib/cobalt/wrappers.c
+++ b/lib/cobalt/wrappers.c
@@ -60,6 +60,12 @@ int __real_pthread_getschedparam(pthread_t thread,
 }
 
 __weak
+int __real_pthread_setschedprio(pthread_t thread, int prio)
+{
+       return pthread_setschedprio(thread, prio);
+}
+
+__weak
 int __real_sched_yield(void)
 {
        return sched_yield();


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

Reply via email to