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

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Mar 11 11:03:23 2010 +0100

rtdk: Introduce assert_nrt_fast

Add assert_nrt_fast as an alternative to assert_nrt which always issues
a syscall when invoked over non-Xenomai thread. assert_nrt_fast uses
xeno_get_current_fast internally, thus suffers from the same inaccuracy
when used in TSD destructors while __thread support is disabled.

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

---

 src/rtdk/assert_context.c |   39 +++++++++++++++++++++++++++------------
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/rtdk/assert_context.c b/src/rtdk/assert_context.c
index f67bcd8..c172b2f 100644
--- a/src/rtdk/assert_context.c
+++ b/src/rtdk/assert_context.c
@@ -25,25 +25,40 @@
 #include <asm-generic/syscall.h>
 #include <asm-generic/bits/current.h>
 
-void assert_nrt(void)
+static void assert_nrt_inner(void)
 {
        xnthread_info_t info;
        int err;
 
-       if (unlikely(xeno_get_current() != XN_NO_HANDLE &&
-                    !(xeno_get_current_mode() & XNRELAX))) {
+       err = XENOMAI_SYSCALL1(__xn_sys_current_info, &info);
 
-               err = XENOMAI_SYSCALL1(__xn_sys_current_info, &info);
+       if (err) {
+               fprintf(stderr, "__xn_sys_current_info failed: %s\n",
+                       strerror(-err));
+               return;
+       }
 
-               if (err) {
-                       fprintf(stderr, "__xn_sys_current_info failed: %s\n",
-                               strerror(-err));
-                       return;
-               }
+       if (info.state & XNTRAPSW)
+               pthread_kill(pthread_self(), SIGXCPU);
+}
 
-               if (info.state & XNTRAPSW)
-                       pthread_kill(pthread_self(), SIGXCPU);
-       }
+void assert_nrt(void)
+{
+       if (unlikely(xeno_get_current() != XN_NO_HANDLE &&
+                    !(xeno_get_current_mode() & XNRELAX)))
+               assert_nrt_inner();
+}
+
+/*
+ * Note: Works without syscalls but may not catch all errors when used inside
+ * TSD destructors (as registered via pthread_key_create) when TLS support
+ * (__thread) is disabled.
+ */
+void assert_nrt_fast(void)
+{
+       if (unlikely(xeno_get_current_fast() != XN_NO_HANDLE &&
+                    !(xeno_get_current_mode() & XNRELAX)))
+               assert_nrt_inner();
 }
 
 /* Memory allocation services */


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

Reply via email to