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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Thu Dec  6 00:04:33 2012 +0100

rtdm: get spinlocks to lock the scheduler

Since it is not always possible to avoid calling rescheduling functions
while holding RTDM spinlocks, and particularly in driver callbacks which
are called with spinlocks locked, get the RTDM spinlocks to lock the scheduler
by using xnpod_lock_sched/xnpod_unlock_sched.

---

 include/rtdm/rtdm_driver.h |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/include/rtdm/rtdm_driver.h b/include/rtdm/rtdm_driver.h
index 3006d59..8b01f04 100644
--- a/include/rtdm/rtdm_driver.h
+++ b/include/rtdm/rtdm_driver.h
@@ -668,7 +668,9 @@ int rtdm_select_bind(int fd, rtdm_selector_t *selector,
        spl_t __rtdm_s;                                 \
                                                        \
        xnlock_get_irqsave(&nklock, __rtdm_s);          \
+       __xnpod_lock_sched();                           \
        code_block;                                     \
+       __xnpod_unlock_sched();                         \
        xnlock_put_irqrestore(&nklock, __rtdm_s);       \
 }
 #endif
@@ -730,6 +732,7 @@ typedef unsigned long rtdm_lockctx_t;
        do {                                                    \
                XENO_BUGON(RTDM, !rthal_local_irq_disabled());  \
                rthal_spin_lock(lock);                          \
+               __xnpod_lock_sched();                           \
        } while (0)
 #endif
 
@@ -749,7 +752,11 @@ typedef unsigned long rtdm_lockctx_t;
  *
  * Rescheduling: never.
  */
-#define rtdm_lock_put(lock)    rthal_spin_unlock(lock)
+#define rtdm_lock_put(lock)                    \
+       do {                                    \
+               rthal_spin_unlock(lock);        \
+               __xnpod_unlock_sched();         \
+       } while (0)
 
 /**
  * Acquire lock and disable preemption
@@ -768,8 +775,11 @@ typedef unsigned long rtdm_lockctx_t;
  *
  * Rescheduling: never.
  */
-#define rtdm_lock_get_irqsave(lock, context)   \
-       rthal_spin_lock_irqsave(lock, context)
+#define rtdm_lock_get_irqsave(lock, context)           \
+       do {                                            \
+               rthal_spin_lock_irqsave(lock, context); \
+               __xnpod_lock_sched();                   \
+       } while (0)
 
 /**
  * Release lock and restore preemption state
@@ -788,8 +798,12 @@ typedef unsigned long rtdm_lockctx_t;
  *
  * Rescheduling: possible.
  */
-#define rtdm_lock_put_irqrestore(lock, context)        \
-       rthal_spin_unlock_irqrestore(lock, context)
+#define rtdm_lock_put_irqrestore(lock, context)                \
+       do {                                            \
+               rthal_spin_unlock(lock);                \
+               __xnpod_unlock_sched();                 \
+               rthal_local_irq_restore(context);       \
+       } while (0)
 
 /**
  * Disable preemption locally


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

Reply via email to