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

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Oct 10 12:43:38 2012 +0200

nucleus: introduce internal sched locking helpers

---

 include/nucleus/pod.h |   44 ++++++++++++++++++++++++++++++++++++++++++--
 ksrc/nucleus/pod.c    |   26 ++++----------------------
 2 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/include/nucleus/pod.h b/include/nucleus/pod.h
index 0c3e10a..06361ff 100644
--- a/include/nucleus/pod.h
+++ b/include/nucleus/pod.h
@@ -288,9 +288,49 @@ static inline void xnpod_schedule(void)
        __xnpod_schedule(sched);
 }
 
-void xnpod_lock_sched(void);
+void ___xnpod_lock_sched(struct xnthread *curr);
 
-void xnpod_unlock_sched(void);
+void ___xnpod_unlock_sched(struct xnthread *curr);
+
+static inline void __xnpod_lock_sched(void)
+{
+       struct xnthread *curr;
+
+       barrier();
+       curr = xnpod_current_thread();
+       ___xnpod_lock_sched(curr);
+}
+
+static inline void __xnpod_unlock_sched(void)
+{
+       struct xnthread *curr;
+
+       barrier();
+       curr = xnpod_current_thread();
+       ___xnpod_unlock_sched(curr);
+}
+
+static inline void xnpod_lock_sched(void)
+{
+       struct xnthread *curr;
+       spl_t s;
+
+       xnlock_get_irqsave(&nklock, s);
+       curr = xnpod_current_thread();
+       ___xnpod_lock_sched(curr);
+       xnlock_put_irqrestore(&nklock, s);
+}
+
+static inline void xnpod_unlock_sched(void)
+{
+       struct xnthread *curr;
+       spl_t s;
+
+       xnlock_get_irqsave(&nklock, s);
+       curr = xnpod_current_thread();
+       ___xnpod_unlock_sched(curr);
+       xnlock_put_irqrestore(&nklock, s);
+}
 
 void xnpod_fire_callouts(xnqueue_t *hookq,
                         xnthread_t *thread);
diff --git a/ksrc/nucleus/pod.c b/ksrc/nucleus/pod.c
index 5aae394..7c56abc 100644
--- a/ksrc/nucleus/pod.c
+++ b/ksrc/nucleus/pod.c
@@ -2336,40 +2336,22 @@ reschedule:
 }
 EXPORT_SYMBOL_GPL(__xnpod_schedule);
 
-void xnpod_lock_sched(void)
+void ___xnpod_lock_sched(struct xnthread *curr)
 {
-       struct xnthread *curr;
-       spl_t s;
-
-       xnlock_get_irqsave(&nklock, s);
-
-       curr = xnpod_current_thread();
-
        if (xnthread_lock_count(curr)++ == 0)
                xnthread_set_state(curr, XNLOCK);
-
-       xnlock_put_irqrestore(&nklock, s);
 }
-EXPORT_SYMBOL_GPL(xnpod_lock_sched);
+EXPORT_SYMBOL_GPL(___xnpod_lock_sched);
 
-void xnpod_unlock_sched(void)
+void ___xnpod_unlock_sched(struct xnthread *curr)
 {
-       struct xnthread *curr;
-       spl_t s;
-
-       xnlock_get_irqsave(&nklock, s);
-
-       curr = xnpod_current_thread();
-
        if (--xnthread_lock_count(curr) == 0) {
                xnthread_clear_state(curr, XNLOCK);
                xnsched_set_self_resched(curr->sched);
                xnpod_schedule();
        }
-
-       xnlock_put_irqrestore(&nklock, s);
 }
-EXPORT_SYMBOL_GPL(xnpod_unlock_sched);
+EXPORT_SYMBOL_GPL(___xnpod_unlock_sched);
 
 /*!
  * \fn int xnpod_add_hook(int type,void (*routine)(xnthread_t *))


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

Reply via email to