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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Sep  4 14:19:33 2011 +0200

nucleus: only update rescnt for XNOTHER threads

---

 ksrc/nucleus/synch.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ksrc/nucleus/synch.c b/ksrc/nucleus/synch.c
index 3a53527..d5ce9aa 100644
--- a/ksrc/nucleus/synch.c
+++ b/ksrc/nucleus/synch.c
@@ -424,7 +424,8 @@ xnflags_t xnsynch_acquire(struct xnsynch *synch, xnticks_t 
timeout,
                                                 XN_NO_HANDLE, threadh);
 
                if (likely(fastlock == XN_NO_HANDLE)) {
-                       xnthread_inc_rescnt(thread);
+                       if (xnthread_test_state(thread, XNOTHER))
+                               xnthread_inc_rescnt(thread);
                        xnthread_clear_info(thread,
                                            XNRMID | XNTIMEO | XNBREAK);
                        return 0;
@@ -475,7 +476,8 @@ xnflags_t xnsynch_acquire(struct xnsynch *synch, xnticks_t 
timeout,
 
                if (!owner) {
                        synch->owner = thread;
-                       xnthread_inc_rescnt(thread);
+                       if (xnthread_test_state(thread, XNOTHER))
+                               xnthread_inc_rescnt(thread);
                        xnthread_clear_info(thread,
                                            XNRMID | XNTIMEO | XNBREAK);
                        goto unlock_and_exit;
@@ -540,7 +542,8 @@ xnflags_t xnsynch_acquire(struct xnsynch *synch, xnticks_t 
timeout,
 
              grab_and_exit:
 
-               xnthread_inc_rescnt(thread);
+               if (xnthread_test_state(thread, XNOTHER))
+                       xnthread_inc_rescnt(thread);
 
                if (use_fastlock) {
                        xnarch_atomic_t *lockp = xnsynch_fastlock(synch);
@@ -719,7 +722,8 @@ struct xnthread *xnsynch_release(struct xnsynch *synch)
        XENO_BUGON(NUCLEUS, !testbits(synch->status, XNSYNCH_OWNER));
 
        lastowner = xnpod_current_thread();
-       xnthread_dec_rescnt(lastowner);
+       if (xnthread_test_state(lastowner, XNOTHER))
+               xnthread_dec_rescnt(lastowner);
        XENO_BUGON(NUCLEUS, xnthread_get_rescnt(lastowner) < 0);
        lastownerh = xnthread_handle(lastowner);
 


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

Reply via email to