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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Jul 31 12:47:52 2013 +0200

cobalt/pod: fix deletion of dormant threads

A dormant thread which receives a cancellation request through
xnpod_cancel_thread() must wake up first, for reaching a cancellation
point asap.

In no way shall this thread's resources be dropped over the caller's
context, this would break the basic assumption with the Cobalt core,
that resources must be claimed on behalf of the exiting thread only.

---

 kernel/cobalt/pod.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/cobalt/pod.c b/kernel/cobalt/pod.c
index 5ff2a9d..3fd270d 100644
--- a/kernel/cobalt/pod.c
+++ b/kernel/cobalt/pod.c
@@ -650,7 +650,7 @@ static inline int moving_target(struct xnsched *sched, 
struct xnthread *thread)
        return ret;
 }
 
-static void cleanup_thread(struct xnthread *thread) /* nklock held, irqs off */
+static inline void cleanup_thread(struct xnthread *thread) /* nklock held, 
irqs off */
 {
        struct xnsched *sched = thread->sched;
 
@@ -764,8 +764,15 @@ void xnpod_cancel_thread(struct xnthread *thread)
 
        xnthread_set_info(thread, XNCANCELD);
 
+       /*
+        * If @thread is not started yet, fake a start request,
+        * raising the kicked condition bit to make sure it will reach
+        * xnpod_testcancel_thread() on its wakeup path.
+        */
        if (xnthread_test_state(thread, XNDORMANT)) {
-               cleanup_thread(thread);
+               xnthread_set_info(thread, XNKICKED);
+               xnpod_resume_thread(thread, XNDORMANT);
+               xnpod_schedule();
                goto unlock_and_exit;
        }
 


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

Reply via email to