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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu May 16 12:51:31 2013 +0200

nucleus/thread: optimize cancellation point traversal

---

 include/cobalt/nucleus/pod.h |   24 ++++++++++++++++++++++--
 kernel/cobalt/nucleus/pod.c  |   21 ++-------------------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/include/cobalt/nucleus/pod.h b/include/cobalt/nucleus/pod.h
index 685f970..632e2a8 100644
--- a/include/cobalt/nucleus/pod.h
+++ b/include/cobalt/nucleus/pod.h
@@ -32,6 +32,7 @@
  *@{*/
 
 #include <nucleus/sched.h>
+#include <nucleus/shadow.h>
 
 /* Pod status flags */
 #define XNFATAL  0x00000001    /* Fatal error in progress */
@@ -194,8 +195,6 @@ int xnpod_start_thread(xnthread_t *thread,
 
 void xnpod_stop_thread(xnthread_t *thread);
 
-void xnpod_testcancel_thread(void);
-
 void xnpod_cancel_thread(xnthread_t *thread);
 
 void xnpod_join_thread(xnthread_t *thread);
@@ -308,6 +307,27 @@ static inline void xnpod_unlock_sched(void)
        xnlock_put_irqrestore(&nklock, s);
 }
 
+void __xnpod_testcancel_thread(struct xnthread *curr);
+
+/**
+ * @fn void xnpod_testcancel_thread(void)
+ *
+ * @brief Introduce a thread cancellation point.
+ *
+ * Terminates the current thread if a cancellation request is pending
+ * for it, i.e. if xnpod_cancel_thread() was called.
+ *
+ * Calling context: This service may be called from all runtime modes
+ * of kernel or user-space threads.
+ */
+static inline void xnpod_testcancel_thread(void)
+{
+       struct xnthread *curr = xnshadow_current();
+
+       if (curr && xnthread_test_info(curr, XNCANCELD))
+               __xnpod_testcancel_thread(curr);
+}
+
 int xnpod_handle_exception(struct ipipe_trap_data *d);
 
 void xnpod_fire_callouts(xnqueue_t *hookq,
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index dc1de97..8917d5c 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -874,31 +874,14 @@ void __xnpod_cleanup_thread(struct xnthread *thread)
        wake_up(&nkjoinq);
 }
 
-/**
- * @fn void xnpod_testcancel_thread(void)
- *
- * @brief Introduce a thread cancellation point.
- *
- * Terminates the current thread if a cancellation request is pending
- * for it, i.e. if xnpod_cancel_thread() was called.
- *
- * Calling context: This service may be called from all runtime modes.
- *
- * Rescheduling: always in case of cancellation from primary mode.
- */
-void xnpod_testcancel_thread(void)
+void __xnpod_testcancel_thread(struct xnthread *curr)
 {
-       struct xnthread *curr = xnshadow_current();
-
-       if (curr == NULL || !xnthread_test_info(curr, XNCANCELD))
-               return;
-
        if (!xnthread_test_state(curr, XNRELAX))
                xnshadow_relax(0, 0);
 
        do_exit(0);
 }
-EXPORT_SYMBOL_GPL(xnpod_testcancel_thread);
+EXPORT_SYMBOL_GPL(__xnpod_testcancel_thread);
 
 /**
  * @fn void xnpod_cancel_thread(struct xnthread *thread)


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

Reply via email to