Hi Gilles,

>> Well, then you need to replace #ifdef CONFIG_PREEMPT_RT with
>> CONFIG_PREEMPT_RT_FULL, and test the kernel version in wrappers.h to
>> define CONFIG_PREEMPT_RT_FULL if CONFIG_PREEMPT_RT is dedined for
>> old kernels.

>I have applied both changes and try if this solves the my problem. If it works 
>I will publish the patch here.

below you can find the patch. It solves the problem concerning "sleeping 
function called from invalid context" when using PREEMPT RT. Would it be 
reasonable to apply that change to GIT repository?

Index: ksrc/arch/generic/hal.c
===================================================================
--- ksrc/arch/generic/hal.c     (Revision 1136)
+++ ksrc/arch/generic/hal.c     (Arbeitskopie)
@@ -355,7 +355,7 @@
     rthal_spin_unlock(&rthal_apc_lock);
 }
 
-#ifdef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_RT_FULL
 
 /* On PREEMPT_RT, we need to invoke the apc handlers over a process
    context, so that the latter can access non-atomic kernel services
@@ -398,11 +398,11 @@
 
 #define rthal_apc_trampoline rthal_apc_kicker
 
-#else /* !CONFIG_PREEMPT_RT */
+#else /* !CONFIG_PREEMPT_RT_FULL */
 
 #define rthal_apc_trampoline rthal_apc_handler
 
-#endif /* CONFIG_PREEMPT_RT */
+#endif /* CONFIG_PREEMPT_RT_FULL */
 
 /**
  * @fn int rthal_apc_alloc (const char *name,void (*handler)(void 
*cookie),void *cookie)
@@ -495,7 +495,7 @@
        clear_bit(apc, &rthal_apc_map);
 }
 
-#ifdef CONFIG_PREEMPT_RT
+#ifdef CONFIG_PREEMPT_RT_FULL
 
 static inline int setup_apc_handler(void)
 {
@@ -524,7 +524,7 @@
        }
 }
 
-#else  /* !CONFIG_PREEMPT_RT */
+#else  /* !CONFIG_PREEMPT_RT_FULL */
 
 static inline int setup_apc_handler(void)
 {
@@ -533,7 +533,7 @@
 
 static inline void cleanup_apc_handler(void) { }
 
-#endif  /* !CONFIG_PREEMPT_RT */
+#endif  /* !CONFIG_PREEMPT_RT_FULL */
 
 int rthal_init(void)
 {
Index: ksrc/nucleus/pipe.c
===================================================================
--- ksrc/nucleus/pipe.c (Revision 1136)
+++ ksrc/nucleus/pipe.c (Arbeitskopie)
@@ -173,7 +173,7 @@
                                        xnlock_get_irqsave(&nklock, s);
                                }
                        }
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
                        /*
                         * Assume a waiter might have entered/left the
                         * queue, so we need to refetch the sleep
@@ -198,7 +198,7 @@
                        xnlock_put_irqrestore(&nklock, s);
                        kill_fasync(&state->asyncq, xnpipe_asyncsig, POLL_IN);
                        xnlock_get_irqsave(&nklock, s);
-#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT)
+#if defined(CONFIG_SMP) || defined(CONFIG_PREEMPT_RT_FULL)
                        nh = getheadq(&xnpipe_asyncq);
 #endif
                }
Index: include/asm-generic/wrappers.h
===================================================================
--- include/asm-generic/wrappers.h      (Revision 1136)
+++ include/asm-generic/wrappers.h      (Arbeitskopie)
@@ -43,6 +43,12 @@
 #include <asm/system.h>
 #endif /* kernel < 3.4.0 */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+#ifdef CONFIG_PREEMPT_RT
+#define CONFIG_PREEMPT_RT_FULL /* after kernel 2.6 CONFIG_PREEMPT_RT was 
renamed */
+#endif
+#endif /* kernel < 3.0.0 */
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 
 #include <linux/wrapper.h>
@@ -664,8 +670,8 @@
 #ifndef DEFINE_SEMAPHORE
 /* Legacy DECLARE_MUTEX vanished in 2.6.37 */
 #define DEFINE_BINARY_SEMAPHORE(sem) DECLARE_MUTEX(sem)
-#elif defined(CONFIG_PREEMPT_RT)
-#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem, 1)
+#elif defined(CONFIG_PREEMPT_RT_FULL)
+#define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #else
 #define DEFINE_BINARY_SEMAPHORE(sem) DEFINE_SEMAPHORE(sem)
 #endif

Regards,
Christoph
_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai

Reply via email to