Module: xenomai-forge
Branch: master
Commit: cea1f8a36052e9707dd537d6d093ffa78044039e
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=cea1f8a36052e9707dd537d6d093ffa78044039e

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Sep  5 14:52:56 2013 +0200

lib/cobalt: switch pthread_create() caller back to primary mode

In addition, cleanup a few wrapped calls to make them unambiguous,
i.e.:

__COBALT()/__RT() => route to lib/cobalt implementation
__STD() => route to glibc implementation
__WRAP() => route to real-time API implementation, defaulting to lib/cobalt

The latter makes sense as an API may override the lib/cobalt
implementation of a set of services.

---

 lib/cobalt/clock.c  |    4 ++--
 lib/cobalt/mutex.c  |    2 +-
 lib/cobalt/thread.c |   15 +++++++--------
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index 4eed916..6145896 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -157,7 +157,7 @@ COBALT_IMPL(int, nanosleep, (const struct timespec *rqtp, 
struct timespec *rmtp)
 {
        int ret;
 
-       ret = __wrap_clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp);
+       ret = __WRAP(clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp));
        if (ret) {
                errno = ret;
                return -1;
@@ -176,7 +176,7 @@ COBALT_IMPL(unsigned int, sleep, (unsigned int seconds))
 
        rqt.tv_sec = seconds;
        rqt.tv_nsec = 0;
-       ret = __wrap_clock_nanosleep(CLOCK_MONOTONIC, 0, &rqt, &rem);
+       ret = __WRAP(clock_nanosleep(CLOCK_MONOTONIC, 0, &rqt, &rem));
        if (ret)
                return rem.tv_sec;
 
diff --git a/lib/cobalt/mutex.c b/lib/cobalt/mutex.c
index 8e8e745..0d0c4b2 100644
--- a/lib/cobalt/mutex.c
+++ b/lib/cobalt/mutex.c
@@ -191,7 +191,7 @@ COBALT_IMPL(int, pthread_mutex_timedlock, (pthread_mutex_t 
*mutex,
        if (_mutex->magic != COBALT_MUTEX_MAGIC)
                return EINVAL;
 
-       /* See __wrap_pthread_mutex_lock() */
+       /* See __cobalt_pthread_mutex_lock() */
        status = cobalt_get_current_mode();
        if ((status & (XNRELAX|XNWEAK)) == 0) {
                err = xnsynch_fast_acquire(mutex_get_ownerp(_mutex), cur);
diff --git a/lib/cobalt/thread.c b/lib/cobalt/thread.c
index d512259..c6db4b0 100644
--- a/lib/cobalt/thread.c
+++ b/lib/cobalt/thread.c
@@ -117,8 +117,7 @@ int pthread_setschedparam_ex(pthread_t thread,
                cobalt_sigshadow_install_once();
                cobalt_set_current();
                cobalt_set_current_window(u_winoff);
-               if (policy != SCHED_OTHER && policy != SCHED_WEAK)
-                       XENOMAI_SYSCALL1(sc_nucleus_migrate, 
XENOMAI_XENO_DOMAIN);
+               __cobalt_thread_harden();
        }
 
        return ret;
@@ -210,7 +209,7 @@ COBALT_IMPL(int, sched_get_priority_max, (int policy))
 
 COBALT_IMPL(int, pthread_yield, (void))
 {
-       return __wrap_sched_yield();
+       return __WRAP(sched_yield());
 }
 
 struct pthread_iargs {
@@ -223,7 +222,7 @@ struct pthread_iargs {
        int ret;
 };
 
-static void *__pthread_trampoline(void *p)
+static void *cobalt_thread_trampoline(void *p)
 {
        /*
         * Volatile is to prevent (too) smart gcc releases from
@@ -280,10 +279,9 @@ sync_with_creator:
         * scheduling order.
         */
        if (param_ex.sched_priority == parent_prio)
-               __wrap_sched_yield();
+               __cobalt_sched_yield();
 
-       if (policy != SCHED_OTHER && policy != SCHED_WEAK)
-               XENOMAI_SYSCALL1(sc_nucleus_migrate, XENOMAI_XENO_DOMAIN);
+       __cobalt_thread_harden();
 
        retval = start(arg);
 
@@ -347,13 +345,14 @@ int pthread_create_ex(pthread_t *tid,
        iargs.ret = EAGAIN;
        __STD(sem_init(&iargs.sync, 0, 0));
 
-       ret = __STD(pthread_create(&ltid, &attr, &__pthread_trampoline, 
&iargs));
+       ret = __STD(pthread_create(&ltid, &attr, cobalt_thread_trampoline, 
&iargs));
        if (ret)
                goto fail;
 
        while (__STD(sem_wait(&iargs.sync)) && errno == EINTR)
                ;
 
+       __cobalt_thread_harden(); /* May fail if regular thread. */
        ret = iargs.ret;
        if (ret == 0)
                *tid = ltid;


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

Reply via email to