[Xenomai-git] Philippe Gerum : boilerplate/libc: provide placeholders for prioceiling ops
Module: xenomai-3 Branch: next Commit: e22c3d3b4f624cee9fc476260bb8269b94cf8507 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e22c3d3b4f624cee9fc476260bb8269b94cf8507 Author: Philippe Gerum Date: Sun Mar 20 17:20:58 2016 +0100 boilerplate/libc: provide placeholders for prioceiling ops --- configure.ac |2 ++ include/boilerplate/libc.h | 19 +++ 2 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 18f3be0..0cbe8b8 100644 --- a/configure.ac +++ b/configure.ac @@ -511,6 +511,8 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \ pthread_mutexattr_getprioceiling \ pthread_mutexattr_setprioceiling \ pthread_mutexattr_setrobust_np \ + pthread_mutex_getprioceiling\ + pthread_mutex_setprioceiling\ pthread_condattr_getclock \ pthread_condattr_setclock \ pthread_spin_lock fork \ diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h index 3a5af8c..2f356a9 100644 --- a/include/boilerplate/libc.h +++ b/include/boilerplate/libc.h @@ -127,6 +127,25 @@ int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * } #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ +#ifndef HAVE_PTHREAD_MUTEX_SETPRIOCEILING +static inline +int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict attr, +int prioceiling, +int *__restrict old_ceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */ + +#ifndef HAVE_PTHREAD_MUTEX_GETPRIOCEILING +static inline +int pthread_mutex_getprioceiling(pthread_mutex_t *__restrict attr, +int *__restrict prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ + #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP #include static inline ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/libc: provide placeholders for prioceiling ops
Module: xenomai-3 Branch: wip/prioceil Commit: 58e42b30f2c9b782139fb858dd1b04b029306079 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=58e42b30f2c9b782139fb858dd1b04b029306079 Author: Philippe Gerum Date: Sun Mar 20 17:20:58 2016 +0100 boilerplate/libc: provide placeholders for prioceiling ops --- configure.ac |2 ++ include/boilerplate/libc.h | 19 +++ 2 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 578327e..88d4e0c 100644 --- a/configure.ac +++ b/configure.ac @@ -507,6 +507,8 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \ pthread_mutexattr_getprioceiling \ pthread_mutexattr_setprioceiling \ pthread_mutexattr_setrobust_np \ + pthread_mutex_getprioceiling\ + pthread_mutex_setprioceiling\ pthread_condattr_getclock \ pthread_condattr_setclock \ pthread_spin_lock fork \ diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h index 3a5af8c..2f356a9 100644 --- a/include/boilerplate/libc.h +++ b/include/boilerplate/libc.h @@ -127,6 +127,25 @@ int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * } #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ +#ifndef HAVE_PTHREAD_MUTEX_SETPRIOCEILING +static inline +int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict attr, +int prioceiling, +int *__restrict old_ceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */ + +#ifndef HAVE_PTHREAD_MUTEX_GETPRIOCEILING +static inline +int pthread_mutex_getprioceiling(pthread_mutex_t *__restrict attr, +int *__restrict prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ + #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP #include static inline ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : cobalt/thread: add schedparam lazy propagation
Module: xenomai-3 Branch: wip/setsched-norelax Commit: 20c1b3146818a6a8ca9eb8c3ea23124fce3b72f2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=20c1b3146818a6a8ca9eb8c3ea23124fce3b72f2 Author: Philippe Gerum Date: Fri Mar 18 12:12:50 2016 +0100 cobalt/thread: add schedparam lazy propagation Provide a mechanism for carrying out a lazy propagation of schedparam updates to the regular kernel, so that userland does not have to switch to secondary mode for this. When userland issues sc_cobalt_thread_setschedparam_ex for updating the scheduling parameters of a Xenomai thread, a request for propagating this change to the regular kernel is made pending. Such request will be committed later, either when: - the thread relaxes if it is running in primary mode when the update request is received; - next time the thread calls back into the Cobalt core as a result of receiving a HOME action from a SIGSHADOW notification, which is sent if such thread was relaxed at the time of the update request. As a result, the target thread will have propagated the schedparams update to the regular kernel as soon as it resumes (relaxed) execution in user-space. --- include/cobalt/kernel/thread.h |8 + include/cobalt/uapi/kernel/thread.h |1 + include/cobalt/uapi/signal.h|1 + kernel/cobalt/posix/syscall.c |9 -- kernel/cobalt/thread.c | 55 +++ 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index 07b6996..a4d826e 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -567,6 +567,14 @@ int xnthread_set_schedparam(struct xnthread *thread, int xnthread_killall(int grace, int mask); +void __xnthread_propagate_schedparam(struct xnthread *curr); + +static inline void xnthread_propagate_schedparam(struct xnthread *curr) +{ + if (xnthread_test_info(curr, XNSCHEDP)) + __xnthread_propagate_schedparam(curr); +} + extern struct xnthread_personality xenomai_personality; /** @} */ diff --git a/include/cobalt/uapi/kernel/thread.h b/include/cobalt/uapi/kernel/thread.h index 0cfc5c8..8d26f16 100644 --- a/include/cobalt/uapi/kernel/thread.h +++ b/include/cobalt/uapi/kernel/thread.h @@ -71,6 +71,7 @@ #define XNROBBED 0x0020 /**< Robbed from resource ownership */ #define XNCANCELD 0x0040 /**< Cancellation request is pending */ #define XNPIALERT 0x0080 /**< Priority inversion alert (SIGDEBUG sent) */ +#define XNSCHEDP 0x0100 /**< schedparam propagation is pending */ /* Local information flags (private to current thread) */ diff --git a/include/cobalt/uapi/signal.h b/include/cobalt/uapi/signal.h index b5483d7..8a7ea15 100644 --- a/include/cobalt/uapi/signal.h +++ b/include/cobalt/uapi/signal.h @@ -47,6 +47,7 @@ /* SIGSHADOW action codes. */ #define SIGSHADOW_ACTION_HARDEN1 #define SIGSHADOW_ACTION_BACKTRACE 2 +#define SIGSHADOW_ACTION_HOME 3 #define SIGSHADOW_BACKTRACE_DEPTH 16 #define SIGDEBUG SIGXCPU diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index a2e87ab..9893b30 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -717,11 +717,16 @@ restart: goto ret_handled; } switched = 1; - } else + } else { /* -* We want to run the syscall in the Linux domain. +* We want to run the syscall in the current Linux +* domain. This is a slow path, so proceed with any +* pending schedparam update on the fly. */ switched = 0; + if (thread) + xnthread_propagate_schedparam(thread); + } ret = handler(__xn_reg_arglist(regs)); if (ret == -ENOSYS && (sysflags & __xn_exec_adaptive) != 0) { diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c index 4325e12..a2ed397 100644 --- a/kernel/cobalt/thread.c +++ b/kernel/cobalt/thread.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -1978,6 +1979,11 @@ int __xnthread_set_schedparam(struct xnthread *thread, thread->lock_count == 0) xnsched_putback(thread); + xnthread_set_info(thread, XNSCHEDP); + /* Ask the target thread to call back if relaxed. */ + if (xnthread_test_state(thread, XNRELAX)) + xnthread_signal(thread, SIGSHADOW, SIGSHADOW_ACTION_HOME); + return ret; } @@ -2099,6 +2105,40 @@ static void post_wakeup(struct task_struct *p) ipipe_post_work_root(&wakework, work); } +void __xnthread_propagate_schedparam(struct xnthread *curr) +{ + int kpolicy = SCHED_FIFO, kprio = curr->bprio, ret; + struct task_struct *p = current; + struct
[Xenomai-git] Philippe Gerum : lib/cobalt/mutex: add support for priority ceiling protocol
Module: xenomai-3 Branch: wip/setsched-norelax Commit: 34042751afac0e22495189fcafe84f1736059339 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=34042751afac0e22495189fcafe84f1736059339 Author: Philippe Gerum Date: Tue Feb 16 10:13:03 2016 +0100 lib/cobalt/mutex: add support for priority ceiling protocol --- configure.ac |2 + include/boilerplate/libc.h | 19 +++ include/cobalt/pthread.h |7 ++ lib/cobalt/cobalt.wrappers |2 + lib/cobalt/init.c |1 + lib/cobalt/internal.h |8 ++ lib/cobalt/mutex.c | 301 +++- lib/cobalt/sched.c | 33 - lib/cobalt/thread.c|7 +- 9 files changed, 311 insertions(+), 69 deletions(-) diff --git a/configure.ac b/configure.ac index 8bbeeef..578327e 100644 --- a/configure.ac +++ b/configure.ac @@ -504,6 +504,8 @@ save_LIBS="$LIBS" LIBS="$LIBS -lrt -lpthread" AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \ pthread_mutexattr_getprotocol \ + pthread_mutexattr_getprioceiling \ + pthread_mutexattr_setprioceiling \ pthread_mutexattr_setrobust_np \ pthread_condattr_getclock \ pthread_condattr_setclock \ diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h index 0e51b86..3a5af8c 100644 --- a/include/boilerplate/libc.h +++ b/include/boilerplate/libc.h @@ -108,6 +108,25 @@ int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * } #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPROTOCOL */ +#ifndef HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING +static inline +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, +int prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */ + +#ifndef HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING +static inline +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * + __restrict attr, +int *__restrict prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ + #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP #include static inline diff --git a/include/cobalt/pthread.h b/include/cobalt/pthread.h index 386c337..f1b1c8a 100644 --- a/include/cobalt/pthread.h +++ b/include/cobalt/pthread.h @@ -67,6 +67,13 @@ COBALT_DECL(int, pthread_mutex_trylock(pthread_mutex_t *mutex)); COBALT_DECL(int, pthread_mutex_unlock(pthread_mutex_t *mutex)); +COBALT_DECL(int, pthread_mutex_setprioceiling(pthread_mutex_t *__restrict mutex, + int prioceiling, + int *__restrict old_ceiling)); + +COBALT_DECL(int, pthread_mutex_getprioceiling(pthread_mutex_t *__restrict mutex, + int *__restrict old_ceiling)); + COBALT_DECL(int, pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr)); diff --git a/lib/cobalt/cobalt.wrappers b/lib/cobalt/cobalt.wrappers index 9480f34..75f29d6 100644 --- a/lib/cobalt/cobalt.wrappers +++ b/lib/cobalt/cobalt.wrappers @@ -32,6 +32,8 @@ --wrap pthread_mutex_trylock --wrap pthread_mutex_timedlock --wrap pthread_mutex_unlock +--wrap pthread_mutex_setprioceiling +--wrap pthread_mutex_getprioceiling --wrap pthread_cond_init --wrap pthread_cond_destroy --wrap pthread_cond_wait diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index f260744..69d4763 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -177,6 +177,7 @@ static void __cobalt_init(void) sizeof(struct cobalt_sem_shadow)); cobalt_mutex_init(); + cobalt_sched_init(); cobalt_thread_init(); cobalt_print_init(); } diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h index fee3fe1..4b8252b 100644 --- a/lib/cobalt/internal.h +++ b/lib/cobalt/internal.h @@ -52,6 +52,8 @@ void cobalt_thread_init(void); int cobalt_thread_probe(pid_t pid); +void cobalt_sched_init(void); + void cobalt_print_init(void); void cobalt_print_init_atfork(void); @@ -73,4 +75,10 @@ void cobalt_check_features(struct cobalt_featinfo *finfo); extern struct sigaction __cobalt_orig_sigdebug; +extern int __cobalt_std_fifo_minpri, + __cobalt_std_fifo_maxpri; + +extern int __cobalt_std_rr_minpri, + __cobalt_std_rr_maxpri; + #endif /* _LIB_COBALT_INTERNAL_H */ diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c index 9d8a914..1456099 100644 --- a/lib/cobalt/mutex.c +++ b/lib/cobalt/mutex.c @@ -99,6 +99,9 @@ void cobalt_mutex_init(void) * mutex, increase CONFIG_XENO_OPT_SHARED_HEAPSZ for a process-shared * mutex, or CONFIG_XENO_OPT_PRIVATE_HEAPSZ for a process-private mutex. * - EAGAIN, no registry slot available, check/raise CONFIG_XENO_OPT_REGISTRY_NRSLOTS. + * - ENOSYS, @a attr mentions pr
[Xenomai-git] Philippe Gerum : cobalt/synch: add support for priority ceiling protocol
Module: xenomai-3 Branch: wip/setsched-norelax Commit: 1d7ebd9240031e3214eb55ca0d20b999f39d43bc URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1d7ebd9240031e3214eb55ca0d20b999f39d43bc Author: Philippe Gerum Date: Tue Feb 16 10:12:55 2016 +0100 cobalt/synch: add support for priority ceiling protocol --- include/cobalt/kernel/heap.h | 11 + include/cobalt/kernel/sched-idle.h | 12 +- include/cobalt/kernel/sched-rt.h | 55 ++- include/cobalt/kernel/sched.h | 94 +++- include/cobalt/kernel/synch.h | 51 ++- include/cobalt/kernel/thread.h | 54 ++- include/cobalt/uapi/asm-generic/features.h | 27 +- include/cobalt/uapi/kernel/synch.h |8 +- include/cobalt/uapi/kernel/thread.h|3 +- include/cobalt/uapi/kernel/types.h |5 +- include/cobalt/uapi/mutex.h|1 + include/cobalt/uapi/thread.h |1 + kernel/cobalt/posix/cond.c |2 +- kernel/cobalt/posix/memory.h |6 + kernel/cobalt/posix/monitor.c | 29 +- kernel/cobalt/posix/mqueue.c |4 +- kernel/cobalt/posix/mutex.c| 103 +++-- kernel/cobalt/posix/process.c | 21 +- kernel/cobalt/posix/process.h |3 +- kernel/cobalt/posix/syscall.c |6 +- kernel/cobalt/posix/timerfd.c |2 +- kernel/cobalt/rtdm/drvlib.c|2 +- kernel/cobalt/sched-idle.c | 12 +- kernel/cobalt/sched-quota.c| 24 +- kernel/cobalt/sched-rt.c | 14 +- kernel/cobalt/sched-sporadic.c | 35 +- kernel/cobalt/sched-tp.c | 42 +- kernel/cobalt/sched-weak.c | 16 +- kernel/cobalt/sched.c | 126 +- kernel/cobalt/synch.c | 636 +++- kernel/cobalt/thread.c | 115 ++--- 31 files changed, 1038 insertions(+), 482 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index a1cea69..d89f25d 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -147,6 +147,17 @@ void xnheap_free(struct xnheap *heap, void *block); int xnheap_check_block(struct xnheap *heap, void *block); +static inline void *xnheap_zalloc(struct xnheap *heap, u32 size) +{ + void *p; + + p = xnheap_alloc(heap, size); + if (p) + memset(p, 0, size); + + return p; +} + static inline char *xnstrdup(const char *s) { char *p; diff --git a/include/cobalt/kernel/sched-idle.h b/include/cobalt/kernel/sched-idle.h index 732ff84..75efdec 100644 --- a/include/cobalt/kernel/sched-idle.h +++ b/include/cobalt/kernel/sched-idle.h @@ -33,11 +33,11 @@ extern struct xnsched_class xnsched_class_idle; -static inline void __xnsched_idle_setparam(struct xnthread *thread, +static inline bool __xnsched_idle_setparam(struct xnthread *thread, const union xnsched_policy_param *p) { xnthread_clear_state(thread, XNWEAK); - thread->cprio = p->idle.prio; + return xnsched_set_effective_priority(thread, p->idle.prio); } static inline void __xnsched_idle_getparam(struct xnthread *thread, @@ -50,11 +50,17 @@ static inline void __xnsched_idle_trackprio(struct xnthread *thread, const union xnsched_policy_param *p) { if (p) - __xnsched_idle_setparam(thread, p); + /* Inheriting a priority-less class makes no sense. */ + XENO_WARN_ON_ONCE(COBALT, 1); else thread->cprio = XNSCHED_IDLE_PRIO; } +static inline void __xnsched_idle_protectprio(struct xnthread *thread, int prio) +{ + XENO_WARN_ON_ONCE(COBALT, 1); +} + static inline int xnsched_idle_init_thread(struct xnthread *thread) { return 0; diff --git a/include/cobalt/kernel/sched-rt.h b/include/cobalt/kernel/sched-rt.h index ffb7223..992a5ba 100644 --- a/include/cobalt/kernel/sched-rt.h +++ b/include/cobalt/kernel/sched-rt.h @@ -67,20 +67,33 @@ static inline void __xnsched_rt_dequeue(struct xnthread *thread) xnsched_delq(&thread->sched->rt.runnable, thread); } -static inline void __xnsched_rt_setparam(struct xnthread *thread, -const union xnsched_policy_param *p) +static inline void __xnsched_rt_track_weakness(struct xnthread *thread) { - thread->cprio = p->rt.prio; - if (!xnthread_test_state(thread, XNBOOST)) { -#ifdef CONFIG_XENO_OPT_SCHED_WEAK + /* +* We have to track threads exiting weak scheduling, i.e. any +* thread leaving the WEAK class code if compiled in, or +* assigned a zero priority if weak threads are hosted by the +* RT class. +* +* CAUTION: since we need
[Xenomai-git] Philippe Gerum : testsuite/smokey: mutex: simplify, introduce PP tests
Module: xenomai-3 Branch: wip/setsched-norelax Commit: fd5b395469ea6f088b3f05995d0df648cfee4fd2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fd5b395469ea6f088b3f05995d0df648cfee4fd2 Author: Philippe Gerum Date: Wed Feb 17 09:21:27 2016 +0100 testsuite/smokey: mutex: simplify, introduce PP tests At this chance, the lock stealing test is also fixed. --- testsuite/smokey/posix-mutex/posix-mutex.c | 1357 ++-- 1 file changed, 670 insertions(+), 687 deletions(-) diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c index ac71b31..ae82fc1 100644 --- a/testsuite/smokey/posix-mutex/posix-mutex.c +++ b/testsuite/smokey/posix-mutex/posix-mutex.c @@ -4,6 +4,7 @@ * Copyright (C) Gilles Chanteperdrix , * Marion Deveaud , * Jan Kiszka + * Philippe Gerum * * Released under the terms of GPLv2. */ @@ -17,8 +18,6 @@ #include #include #include -#include -#include "lib/cobalt/current.h" #include smokey_test_plugin(posix_mutex, @@ -26,886 +25,870 @@ smokey_test_plugin(posix_mutex, "Check POSIX mutex services" ); -#define MUTEX_CREATE 1 -#define MUTEX_LOCK 2 -#define MUTEX_TRYLOCK 3 -#define MUTEX_TIMED_LOCK 4 -#define MUTEX_UNLOCK 5 -#define MUTEX_DESTROY 6 -#define COND_CREATE7 -#define COND_SIGNAL8 -#define COND_WAIT 9 -#define COND_DESTROY 10 -#define THREAD_DETACH 11 -#define THREAD_CREATE 12 -#define THREAD_JOIN13 -#define THREAD_RENICE 14 - -#define NS_PER_MS 100 - static const char *reason_str[] = { - [SIGDEBUG_UNDEFINED] = "undefined", + [SIGDEBUG_UNDEFINED] = "received SIGDEBUG for unknown reason", [SIGDEBUG_MIGRATE_SIGNAL] = "received signal", [SIGDEBUG_MIGRATE_SYSCALL] = "invoked syscall", [SIGDEBUG_MIGRATE_FAULT] = "triggered fault", [SIGDEBUG_MIGRATE_PRIOINV] = "affected by priority inversion", - [SIGDEBUG_NOMLOCK] = "missing mlockall", - [SIGDEBUG_WATCHDOG] = "runaway thread", + [SIGDEBUG_NOMLOCK] = "process memory not locked", + [SIGDEBUG_WATCHDOG] = "watchdog triggered (period too short?)", + [SIGDEBUG_LOCK_BREAK] = "scheduler lock break", }; static void sigdebug(int sig, siginfo_t *si, void *context) { + const char fmt[] = "%s, this is unexpected.\n" + "(enabling CONFIG_XENO_OPT_DEBUG_TRACE_RELAX may help)\n"; unsigned int reason = sigdebug_reason(si); + int n __attribute__ ((unused)); + static char buffer[256]; - smokey_trace("\nSIGDEBUG received, reason %d: %s\n", reason, -reason <= SIGDEBUG_WATCHDOG ? reason_str[reason] : ""); -} + if (reason > SIGDEBUG_WATCHDOG) + reason = SIGDEBUG_UNDEFINED; -static inline unsigned long long timer_get_tsc(void) -{ - return clockobj_get_tsc(); + n = snprintf(buffer, sizeof(buffer), fmt, reason_str[reason]); + n = write(STDERR_FILENO, buffer, n); } -static inline unsigned long long timer_tsc2ns(unsigned long long tsc) -{ - return clockobj_tsc_to_ns(tsc); -} +#define THREAD_PRIO_WEAK 0 +#define THREAD_PRIO_LOW1 +#define THREAD_PRIO_MEDIUM 2 +#define THREAD_PRIO_HIGH 3 +#define THREAD_PRIO_VERY_HIGH 4 -static void add_timespec(struct timespec *ts, unsigned long long value) -{ - ts->tv_sec += value / 10; - ts->tv_nsec += value % 10; - if (ts->tv_nsec > 10) { - ts->tv_sec++; - ts->tv_nsec -= 10; - } -} +#define MAX_100_MS 1ULL + +struct locker_context { + pthread_mutex_t *mutex; + struct smokey_barrier *barrier; + int lock_acquired; +}; -static void ms_sleep(int time) +static void sleep_ms(unsigned int ms) /* < 1000 */ { struct timespec ts; - + ts.tv_sec = 0; - ts.tv_nsec = time*NS_PER_MS; - - nanosleep(&ts, NULL); + ts.tv_nsec = ms * 100; + clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL); } -static void check_current_prio(int expected_prio) +static int get_effective_prio(void) { struct cobalt_threadstat stat; int ret; ret = cobalt_thread_stat(0, &stat); - if (ret) { - fprintf(stderr, - "FAILURE: cobalt_threadstat (%s)\n", strerror(-ret)); - exit(EXIT_FAILURE); - } + if (ret) + return ret; - if (stat.cprio != expected_prio) { - fprintf(stderr, - "FAILURE: current prio (%d) != expected prio (%d)\n", - stat.cprio, expected_prio); - exit(EXIT_FAILURE); - } + return stat.cprio; } -static void __check_current_mode(const char *file, int line, -
[Xenomai-git] Jan Kiszka : smokey/posix-mutex: Fix test case /wrt mutex object reuse
Module: xenomai-3 Branch: wip/setsched-norelax Commit: d138f8c918cebfefa51acfa41f4d6ae60942a76a URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d138f8c918cebfefa51acfa41f4d6ae60942a76a Author: Jan Kiszka Date: Thu Feb 25 11:29:00 2016 +0100 smokey/posix-mutex: Fix test case /wrt mutex object reuse Mutex objects created on the stack must be properly destroyed after use. Otherwise, succeeding tests that use the same stack layout will consider them busy and refuse to recreate the mutexes. Signed-off-by: Jan Kiszka --- testsuite/smokey/posix-mutex/posix-mutex.c | 26 +- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c index ae82fc1..151c2f3 100644 --- a/testsuite/smokey/posix-mutex/posix-mutex.c +++ b/testsuite/smokey/posix-mutex/posix-mutex.c @@ -623,7 +623,10 @@ static int protect_raise(void) if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex))) + return ret; + return 0; } @@ -651,7 +654,10 @@ static int protect_lower(void) if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex))) + return ret; + return 0; } @@ -699,7 +705,10 @@ static int protect_weak(void) if (!__T(ret, pthread_setschedparam(pthread_self(), old_policy, &old_param))) return ret; - + + if (!__T(ret, pthread_mutex_destroy(&mutex))) + return ret; + return 0; } @@ -745,7 +754,11 @@ static int protect_nesting_protect(void) if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex_high)) || + !__T(ret, pthread_mutex_destroy(&mutex_very_high))) + return ret; + return 0; } @@ -782,7 +795,10 @@ static int protect_nesting_pi(void) /* PP boost just dropped: HIGH -> MEDIUM. */ if (!__Tassert(get_effective_prio() == THREAD_PRIO_MEDIUM)) return -EINVAL; - + + if (!__T(ret, pthread_mutex_destroy(&mutex_pp))) + return ret; + return 0; } ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : boilerplate/libc: provide placeholders for prioceiling ops
Module: xenomai-3 Branch: wip/setsched-norelax Commit: 58e42b30f2c9b782139fb858dd1b04b029306079 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=58e42b30f2c9b782139fb858dd1b04b029306079 Author: Philippe Gerum Date: Sun Mar 20 17:20:58 2016 +0100 boilerplate/libc: provide placeholders for prioceiling ops --- configure.ac |2 ++ include/boilerplate/libc.h | 19 +++ 2 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 578327e..88d4e0c 100644 --- a/configure.ac +++ b/configure.ac @@ -507,6 +507,8 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol \ pthread_mutexattr_getprioceiling \ pthread_mutexattr_setprioceiling \ pthread_mutexattr_setrobust_np \ + pthread_mutex_getprioceiling\ + pthread_mutex_setprioceiling\ pthread_condattr_getclock \ pthread_condattr_setclock \ pthread_spin_lock fork \ diff --git a/include/boilerplate/libc.h b/include/boilerplate/libc.h index 3a5af8c..2f356a9 100644 --- a/include/boilerplate/libc.h +++ b/include/boilerplate/libc.h @@ -127,6 +127,25 @@ int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * } #endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ +#ifndef HAVE_PTHREAD_MUTEX_SETPRIOCEILING +static inline +int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict attr, +int prioceiling, +int *__restrict old_ceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_SETPRIOCEILING */ + +#ifndef HAVE_PTHREAD_MUTEX_GETPRIOCEILING +static inline +int pthread_mutex_getprioceiling(pthread_mutex_t *__restrict attr, +int *__restrict prioceiling) +{ + return ENOSYS; +} +#endif /* !HAVE_PTHREAD_MUTEXATTR_GETPRIOCEILING */ + #ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP #include static inline ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : lib/cobalt: use lazy schedparam propagation
Module: xenomai-3 Branch: wip/setsched-norelax Commit: 3941766a289a7bbcf6a85989e37474859c7bb6b2 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=3941766a289a7bbcf6a85989e37474859c7bb6b2 Author: Philippe Gerum Date: Fri Mar 18 12:12:27 2016 +0100 lib/cobalt: use lazy schedparam propagation Do not switch to secondary mode upon schedparam updates for propagating changes to the regular kernel, if the caller runs in primary mode when entering pthread_setschedparam*() or sched_setscheduler(). In such a case, the update request to the regular kernel is left pending until the target thread resumes execution in relaxed mode, at which point it is committed. CAUTION: This mechanism won't update the schedparams cached by the glibc for the caller in user-space, but this is the deal: we don't relax threads which issue pthread_setschedparam[_ex]() from primary mode anymore, but then only the kernel side (Cobalt and the host kernel) will be aware of the change, and glibc might cache obsolete information. If the caller already runs in relaxed mode on entry to these services, the update request takes place immediately, via the regular (g)libc calls. In any case, the new scheduling parameters for the target thread are immediately applied by Cobalt, regardless of the update path followed for the regular kernel. --- lib/cobalt/internal.c | 44 ++ lib/cobalt/sched.c | 13 lib/cobalt/sigshadow.c |8 + lib/cobalt/thread.c| 80 +--- 4 files changed, 87 insertions(+), 58 deletions(-) diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c index 5b89db5..cb1d53b 100644 --- a/lib/cobalt/internal.c +++ b/lib/cobalt/internal.c @@ -514,3 +514,47 @@ int cobalt_sched_weighted_prio(int policy, { return XENOMAI_SYSCALL2(sc_cobalt_sched_weightprio, policy, param_ex); } + +int cobalt_xlate_schedparam(int policy, + const struct sched_param_ex *param_ex, + struct sched_param *param) +{ + int std_policy, priority; + + /* +* Translates Cobalt scheduling parameters to native ones, +* based on a best approximation for Cobalt policies which are +* not available from the host kernel. +*/ + std_policy = policy; + priority = param_ex->sched_priority; + + switch (policy) { + case SCHED_WEAK: + std_policy = priority ? SCHED_FIFO : SCHED_OTHER; + break; + default: + std_policy = SCHED_FIFO; + /* falldown wanted. */ + case SCHED_OTHER: + case SCHED_FIFO: + case SCHED_RR: + /* +* The Cobalt priority range is larger than those of +* the native SCHED_FIFO/RR classes, so we have to cap +* the priority value accordingly. We also remap +* "weak" (negative) priorities - which are only +* meaningful for the Cobalt core - to regular values. +*/ + if (priority > __cobalt_std_fifo_maxpri) + priority = __cobalt_std_fifo_maxpri; + } + + if (priority < 0) + priority = -priority; + + memset(param, 0, sizeof(*param)); + param->sched_priority = priority; + + return std_policy; +} diff --git a/lib/cobalt/sched.c b/lib/cobalt/sched.c index b0292b5..87b9235 100644 --- a/lib/cobalt/sched.c +++ b/lib/cobalt/sched.c @@ -26,7 +26,6 @@ #include #include #include -#include "current.h" #include "internal.h" /** @@ -297,11 +296,13 @@ int sched_setscheduler_ex(pid_t pid, return EINVAL; /* See pthread_setschedparam_ex(). */ - - std_policy = cobalt_xlate_schedparam(policy, param_ex, &std_param); - ret = __STD(sched_setscheduler(pid, std_policy, &std_param)); - if (ret) - return errno; + + if (cobalt_is_relaxed()) { + std_policy = cobalt_xlate_schedparam(policy, param_ex, &std_param); + ret = __STD(sched_setscheduler(pid, std_policy, &std_param)); + if (ret) + return errno; + } ret = -XENOMAI_SYSCALL5(sc_cobalt_sched_setscheduler_ex, pid, policy, param_ex, diff --git a/lib/cobalt/sigshadow.c b/lib/cobalt/sigshadow.c index 3f4e9c5..48d5a81 100644 --- a/lib/cobalt/sigshadow.c +++ b/lib/cobalt/sigshadow.c @@ -59,6 +59,14 @@ int cobalt_sigshadow_handler(int sig, siginfo_t *si, void *ctxt) skip = nr > 3 ? 3 : 0; XENOMAI_SYSCALL3(sc_cobalt_backtrace, nr - skip, frames + skip, arg); break; + case SIGSHADOW_ACTION_HOME: + /* +* We have been asked to call home from the current +* context: sending a query for retrieving our handle +* will just do this. +
[Xenomai-git] Philippe Gerum : lib/cobalt: add config switch to enable lazy setsched update mode
Module: xenomai-3 Branch: next Commit: 867070475384652b4e3d4a25f5ad983732a59a7e URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=867070475384652b4e3d4a25f5ad983732a59a7e Author: Philippe Gerum 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 0cbe8b8..cd9f047 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
[Xenomai-git] Philippe Gerum : config: bump version info to 3.1-devel
Module: xenomai-3 Branch: next Commit: dc0fd746ea6ad2d17b5ccf2217a6dfa56087d396 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=dc0fd746ea6ad2d17b5ccf2217a6dfa56087d396 Author: Philippe Gerum Date: Sun Mar 20 18:51:17 2016 +0100 config: bump version info to 3.1-devel --- config/version-code |2 +- config/version-label |2 +- config/version-name |2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/version-code b/config/version-code index cb2b00e..ddd61cc 100644 --- a/config/version-code +++ b/config/version-code @@ -1 +1 @@ -3.0.1 +3.0.90 diff --git a/config/version-label b/config/version-label index cb2b00e..302fdd0 100644 --- a/config/version-label +++ b/config/version-label @@ -1 +1 @@ -3.0.1 +3.1-devel diff --git a/config/version-name b/config/version-name index 272395d..8c51501 100644 --- a/config/version-name +++ b/config/version-name @@ -1 +1 @@ -Exact Zero +Xenomai -next ___ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Philippe Gerum : doc: prebuild
Module: xenomai-3 Branch: next Commit: e07ef441d0069f16364eeaa6b4c8a5680f6abf57 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e07ef441d0069f16364eeaa6b4c8a5680f6abf57 Author: Philippe Gerum Date: Sun Mar 20 19:34:22 2016 +0100 doc: prebuild --- doc/asciidoc/README.INSTALL.adoc | 26 +- doc/asciidoc/TROUBLESHOOTING.COBALT.adoc | 11 +- doc/prebuilt/html/MIGRATION/index.html |6 +- doc/prebuilt/html/README.APPLICATIONS/index.html |2 +- doc/prebuilt/html/README.INSTALL/index.html| 32 +- .../html/TROUBLESHOOTING.COBALT/index.html | 15 +- .../html/TROUBLESHOOTING.MERCURY/index.html|2 +- doc/prebuilt/html/man1/autotune/index.html |2 +- doc/prebuilt/html/man1/clocktest/index.html|2 +- doc/prebuilt/html/man1/corectl/index.html |2 +- doc/prebuilt/html/man1/dohell/index.html |2 +- doc/prebuilt/html/man1/latency/index.html |2 +- doc/prebuilt/html/man1/rtcanconfig/index.html |2 +- doc/prebuilt/html/man1/rtcanrecv/index.html|2 +- doc/prebuilt/html/man1/rtcansend/index.html|2 +- doc/prebuilt/html/man1/slackspot/index.html|2 +- doc/prebuilt/html/man1/switchtest/index.html |2 +- doc/prebuilt/html/man1/xeno-config/index.html |2 +- doc/prebuilt/html/man1/xeno-test/index.html|2 +- doc/prebuilt/html/man1/xeno/index.html |2 +- .../html/xeno3prm/16550A__io_8h_source.html| 10 +- .../html/xeno3prm/16550A__pci_8h_source.html | 10 +- .../html/xeno3prm/16550A__pnp_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/8255_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/af__inet_8h_source.html | 10 +- .../html/xeno3prm/alchemy_2compat_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/analogy_2driver_8h.html | 48 +- .../html/xeno3prm/analogy_2driver_8h__incl.map | 58 +- .../html/xeno3prm/analogy_2driver_8h__incl.md5 |2 +- .../html/xeno3prm/analogy_2driver_8h__incl.png | Bin 271875 -> 289554 bytes .../html/xeno3prm/analogy_2driver_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/analogy_8h.html | 33 +- doc/prebuilt/html/xeno3prm/analogy_8h__incl.map| 26 +- doc/prebuilt/html/xeno3prm/analogy_8h__incl.md5|2 +- doc/prebuilt/html/xeno3prm/analogy_8h__incl.png| Bin 66461 -> 69464 bytes doc/prebuilt/html/xeno3prm/analogy_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/annotated.html | 10 +- doc/prebuilt/html/xeno3prm/annotated_dup.js| 54 + doc/prebuilt/html/xeno3prm/apc_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/api-tags.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 149 ++ ...include_2asm_2xenomai_2syscall32_8h_source.html | 133 ++ ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ..._2include_2asm_2xenomai_2machine_8h_source.html | 10 +- ...include_2asm_2xenomai_2syscall32_8h_source.html | 10 +- ...4_2include_2asm_2xenomai_2fptest_8h_source.html | 156 ++ ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html | 214 ++ ...m_2include_2asm_2xenomai_2fptest_8h_source.html | 10 +- ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/arp_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/assert_8h_source.html | 57 +- doc/prebuilt/html/xeno3prm/async_8c.html | 34 +- doc/prebuilt/html/xeno3prm/async_8c__incl.map | 44 +- doc/prebuilt/html/xeno3prm/async_8c__incl.md5 |2 +- doc/prebuilt/html/xeno3prm/async_8c__incl.png | Bin 117906 -> 139291 bytes doc/prebuilt/html/xeno3prm/atomic_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/bheap_8h_source.html| 10 +- ...n_2include_2asm_2xenomai_2fptest_8h_source.html | 10 +- ...lude_2asm_2xenomai_2uapi_2fptest_8h_source.html | 10 +- .../boilerplate_2ancillaries_8h_source.html| 217 +- .../html/xeno3prm/boilerplate_2list_8h_source.html | 10 +- .../html/xeno3prm/boilerplate_2lock_8h_source.html | 393 ++-- .../html/xeno3prm/boilerplate_2time_8h_source.html | 10 +- .../xeno3prm/boilerplate_2tunables_8h_source.html | 34 +- doc/prebuilt/html/xeno3prm/bufd_8h_source.html | 10 +- .../html/xeno3prm/bufp-label_8c-example.html | 10 +- .../html/xeno3prm/bufp-readwrite_8c-example.html | 10 +- doc/prebuilt/html/xeno3prm/c1e_8h_source.html | 10 +- doc/prebuilt/html/xeno3prm/calibration_8c.html | 28 +- .../html/xeno3prm/calibration_8c__incl.map | 32 +- .../html/xeno3prm/cal