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

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

nucleus: introduce internal sched locking helpers

---

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

diff --git a/include/cobalt/nucleus/pod.h b/include/cobalt/nucleus/pod.h
index 172388b..1cf2e42 100644
--- a/include/cobalt/nucleus/pod.h
+++ b/include/cobalt/nucleus/pod.h
@@ -277,9 +277,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);
+}
 
 int xnpod_handle_exception(struct ipipe_trap_data *d);
 
diff --git a/kernel/cobalt/nucleus/pod.c b/kernel/cobalt/nucleus/pod.c
index 1bcaf3d..fa26b31 100644
--- a/kernel/cobalt/nucleus/pod.c
+++ b/kernel/cobalt/nucleus/pod.c
@@ -2187,40 +2187,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