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

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sun Sep  4 14:38:55 2011 +0200

nucleus: fix xnsynch_release_all_ownership

By not assuming that synch owner is current thread.

---

 ksrc/nucleus/synch.c |   89 ++++++++++++++++++++++++++------------------------
 1 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/ksrc/nucleus/synch.c b/ksrc/nucleus/synch.c
index d5ce9aa..b956e46 100644
--- a/ksrc/nucleus/synch.c
+++ b/ksrc/nucleus/synch.c
@@ -673,55 +673,17 @@ void xnsynch_requeue_sleeper(struct xnthread *thread)
 }
 EXPORT_SYMBOL_GPL(xnsynch_requeue_sleeper);
 
-/*!
- * \fn struct xnthread *xnsynch_release(struct xnsynch *synch);
- * \brief Give the resource ownership to the next waiting thread.
- *
- * This service releases the ownership of the given synchronization
- * object. The thread which is currently leading the object's pending
- * list, if any, is unblocked from its pending state. However, no
- * reschedule is performed.
- *
- * This service must be used only with synchronization objects that
- * track ownership (XNSYNCH_OWNER set).
- *
- * @param synch The descriptor address of the synchronization object
- * whose ownership is changed.
- *
- * @return The descriptor address of the unblocked thread.
- *
- * Side-effects:
- *
- * - The effective priority of the previous resource owner might be
- * lowered to its base priority value as a consequence of the priority
- * inheritance boost being cleared.
- *
- * - The synchronization object ownership is transfered to the
- * unblocked thread.
- *
- * Environments:
- *
- * This service can be called from:
- *
- * - Kernel module initialization/cleanup code
- * - Interrupt service routine
- * - Kernel-based task
- * - User-space task
- *
- * Rescheduling: never.
- */
-
-struct xnthread *xnsynch_release(struct xnsynch *synch)
+static struct xnthread *
+xnsynch_release_thread(struct xnsynch *synch, struct xnthread *lastowner)
 {
        const int use_fastlock = xnsynch_fastlock_p(synch);
-       struct xnthread *newowner, *lastowner;
        xnhandle_t lastownerh, newownerh;
+       struct xnthread *newowner;
        struct xnpholder *holder;
        spl_t s;
 
        XENO_BUGON(NUCLEUS, !testbits(synch->status, XNSYNCH_OWNER));
 
-       lastowner = xnpod_current_thread();
        if (xnthread_test_state(lastowner, XNOTHER))
                xnthread_dec_rescnt(lastowner);
        XENO_BUGON(NUCLEUS, xnthread_get_rescnt(lastowner) < 0);
@@ -740,7 +702,6 @@ struct xnthread *xnsynch_release(struct xnsynch *synch)
                newowner = link2thread(holder, plink);
                newowner->wchan = NULL;
                newowner->wwake = synch;
-               lastowner = synch->owner;
                synch->owner = newowner;
                xnthread_set_info(newowner, XNWAKEN);
                xnpod_resume_thread(newowner, XNPEND);
@@ -766,6 +727,48 @@ struct xnthread *xnsynch_release(struct xnsynch *synch)
 
        return newowner;
 }
+
+/*!
+ * \fn struct xnthread *xnsynch_release(struct xnsynch *synch);
+ * \brief Give the resource ownership to the next waiting thread.
+ *
+ * This service releases the ownership of the given synchronization
+ * object. The thread which is currently leading the object's pending
+ * list, if any, is unblocked from its pending state. However, no
+ * reschedule is performed.
+ *
+ * This service must be used only with synchronization objects that
+ * track ownership (XNSYNCH_OWNER set).
+ *
+ * @param synch The descriptor address of the synchronization object
+ * whose ownership is changed.
+ *
+ * @return The descriptor address of the unblocked thread.
+ *
+ * Side-effects:
+ *
+ * - The effective priority of the previous resource owner might be
+ * lowered to its base priority value as a consequence of the priority
+ * inheritance boost being cleared.
+ *
+ * - The synchronization object ownership is transfered to the
+ * unblocked thread.
+ *
+ * Environments:
+ *
+ * This service can be called from:
+ *
+ * - Kernel module initialization/cleanup code
+ * - Interrupt service routine
+ * - Kernel-based task
+ * - User-space task
+ *
+ * Rescheduling: never.
+ */
+struct xnthread *xnsynch_release(struct xnsynch *synch)
+{
+       return xnsynch_release_thread(synch, xnpod_current_thread());
+}
 EXPORT_SYMBOL_GPL(xnsynch_release);
 
 /*!
@@ -981,7 +984,7 @@ void xnsynch_release_all_ownerships(struct xnthread *thread)
                 */
                synch = link2synch(holder);
                nholder = nextpq(&thread->claimq, holder);
-               xnsynch_release(synch);
+               xnsynch_release_thread(synch, thread);
                if (synch->cleanup)
                        synch->cleanup(synch);
        }


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

Reply via email to