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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Mon Jul 18 14:07:00 2011 +0200

nucleus: Fix racy Linux task state manipulation

xnshadow_relax can race with do_sigwake_event on a different CPU /wrt
manipulating the Linux task state. Fix this by taking nklock before
calling clear_task_nowakeup.

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

---

 ksrc/nucleus/shadow.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
index 7e87d7c..b51d186 100644
--- a/ksrc/nucleus/shadow.c
+++ b/ksrc/nucleus/shadow.c
@@ -1141,8 +1141,15 @@ void xnshadow_relax(int notify, int reason)
        splmax();
        rpi_push(thread->sched, thread);
        schedule_linux_call(LO_WAKEUP_REQ, current, 0);
+
+       /*
+        * Task nklock to synchronize the Linux task state manipulation with
+        * do_sigwake_event. nklock will be released by xnpod_suspend_thread.
+        */
+       xnlock_get(&nklock);
        clear_task_nowakeup(current);
        xnpod_suspend_thread(thread, XNRELAX, XN_INFINITE, XN_RELATIVE, NULL);
+
        splnone();
        if (XENO_DEBUG(NUCLEUS) && rthal_current_domain != rthal_root_domain)
                xnpod_fatal("xnshadow_relax() failed for thread %s[%d]",


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

Reply via email to