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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Fri Jul 17 16:54:47 2015 +0200

cobalt/synch: test information bits as returned by xnsynch_acquire() only

Callers of xnsynch_acquire() MUST retrieve the information bits from
the return value, instead of peeking into the current thread's TCB.

As a consequence of this rule, we don't have to serialize for clearing
those bits in the TCB when the resource is readily available upon
call.

---

 kernel/cobalt/posix/mutex.c |   15 ++++++++-------
 kernel/cobalt/synch.c       |    5 +----
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c
index d9ebdfb..58b4f3f 100644
--- a/kernel/cobalt/posix/mutex.c
+++ b/kernel/cobalt/posix/mutex.c
@@ -65,20 +65,21 @@ int __cobalt_mutex_acquire_unchecked(struct xnthread *cur,
                                     struct cobalt_mutex *mutex,
                                     const struct timespec *ts)
 {
+       int ret;
+
        if (ts) {
                if (ts->tv_nsec >= ONE_BILLION)
                        return -EINVAL;
-               xnsynch_acquire(&mutex->synchbase, ts2ns(ts) + 1, XN_REALTIME);
+               ret = xnsynch_acquire(&mutex->synchbase, ts2ns(ts) + 1, 
XN_REALTIME);
        } else
-               xnsynch_acquire(&mutex->synchbase, XN_INFINITE, XN_RELATIVE);
+               ret = xnsynch_acquire(&mutex->synchbase, XN_INFINITE, 
XN_RELATIVE);
 
-       if (xnthread_test_info(cur, XNBREAK | XNRMID | XNTIMEO)) {
-               if (xnthread_test_info(cur, XNBREAK))
+       if (ret) {
+               if (ret & XNBREAK)
                        return -EINTR;
-               else if (xnthread_test_info(cur, XNTIMEO))
+               if (ret & XNTIMEO)
                        return -ETIMEDOUT;
-               else /* XNRMID */
-                       return -EINVAL;
+               return -EINVAL;
        }
 
        return 0;
diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c
index 5b2d839..8787206 100644
--- a/kernel/cobalt/synch.c
+++ b/kernel/cobalt/synch.c
@@ -443,9 +443,6 @@ redo:
        if (likely(h == XN_NO_HANDLE)) {
                xnsynch_set_owner(synch, curr);
                xnthread_get_resource(curr);
-               xnlock_get_irqsave(&nklock, s);
-               xnthread_clear_info(curr, XNRMID | XNTIMEO | XNBREAK);
-               xnlock_put_irqrestore(&nklock, s);
                return 0;
        }
 
@@ -559,7 +556,7 @@ block:
 out:
        xnlock_put_irqrestore(&nklock, s);
 
-       return (int)xnthread_test_info(curr, XNRMID|XNTIMEO|XNBREAK);
+       return xnthread_test_info(curr, XNRMID|XNTIMEO|XNBREAK);
 }
 EXPORT_SYMBOL_GPL(xnsynch_acquire);
 


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

Reply via email to