Module: xenomai-jki
Branch: for-upstream
Commit: 6c937abaa18f36b45340a612ed907cde20b6b970
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=6c937abaa18f36b45340a612ed907cde20b6b970

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Sun Apr 25 16:20:51 2010 +0200

nucleus: Fix bogus lock stealing case

See "deny_stealing" mutex test case for the detailed scenario. The bug
was caused by XNWAKEN/wwake remaining untouched when returning from
xnsynch_acquire with the lock held. Namely, the robbed original owner
restarted the acquisition and grabbed the lock in the fast path without
properly resetting XNWAKEN. This happens now right after returning from
xnpod_suspend_thread (we can only gain this state when entering
suspension).

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

---

 ksrc/nucleus/synch.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ksrc/nucleus/synch.c b/ksrc/nucleus/synch.c
index d57f7cd..15662da 100644
--- a/ksrc/nucleus/synch.c
+++ b/ksrc/nucleus/synch.c
@@ -514,6 +514,9 @@ xnflags_t xnsynch_acquire(struct xnsynch *synch, xnticks_t 
timeout,
 
        xnpod_suspend_thread(thread, XNPEND, timeout, timeout_mode, synch);
 
+       thread->wwake = NULL;
+       xnthread_clear_info(thread, XNWAKEN);
+
        if (xnthread_test_info(thread, XNRMID | XNTIMEO | XNBREAK))
                goto unlock_and_exit;
 
@@ -548,9 +551,6 @@ xnflags_t xnsynch_acquire(struct xnsynch *synch, xnticks_t 
timeout,
 
       unlock_and_exit:
 
-       thread->wwake = NULL;
-       xnthread_clear_info(thread, XNWAKEN);
-
        xnlock_put_irqrestore(&nklock, s);
 
        return xnthread_test_info(thread, XNRMID|XNTIMEO|XNBREAK);


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

Reply via email to