Module: xenomai-3 Branch: next Commit: 5c8c1e2c1ba9a966ea565bc050e6ec384cd48aa6 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=5c8c1e2c1ba9a966ea565bc050e6ec384cd48aa6
Author: Jan Kiszka <jan.kis...@siemens.com> Date: Mon May 9 21:19:04 2016 +0200 cobalt/kernel: Return need_resched flag from xnsynch_release We currently return the next owner, but no caller of xnsynch_release evaluates this beyond != NULL and calls xnsched_run in that case. Simplify the API by returning a need_resched flag directly. This will also help with fixing the missing reschedule after PP deboost. Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- include/cobalt/kernel/synch.h | 3 +-- kernel/cobalt/posix/mutex.c | 2 +- kernel/cobalt/rtdm/drvlib.c | 2 +- kernel/cobalt/synch.c | 23 +++++++++++------------ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/cobalt/kernel/synch.h b/include/cobalt/kernel/synch.h index 246d2b9..b3a8004 100644 --- a/include/cobalt/kernel/synch.h +++ b/include/cobalt/kernel/synch.h @@ -164,8 +164,7 @@ int __must_check xnsynch_acquire(struct xnsynch *synch, int __must_check xnsynch_try_acquire(struct xnsynch *synch); -struct xnthread *xnsynch_release(struct xnsynch *synch, - struct xnthread *thread); +bool xnsynch_release(struct xnsynch *synch, struct xnthread *thread); struct xnthread *xnsynch_peek_pendq(struct xnsynch *synch); diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c index c6020ff..f99874b 100644 --- a/kernel/cobalt/posix/mutex.c +++ b/kernel/cobalt/posix/mutex.c @@ -128,7 +128,7 @@ int cobalt_mutex_release(struct xnthread *curr, cobalt_cond_deferred_signals(cond); } } - need_resched |= xnsynch_release(&mutex->synchbase, curr) != NULL; + need_resched |= xnsynch_release(&mutex->synchbase, curr); return need_resched; } diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c index 248a9a8..6f4f51e 100644 --- a/kernel/cobalt/rtdm/drvlib.c +++ b/kernel/cobalt/rtdm/drvlib.c @@ -1282,7 +1282,7 @@ void rtdm_mutex_unlock(rtdm_mutex_t *mutex) trace_cobalt_driver_mutex_release(mutex); if (unlikely(xnsynch_release(&mutex->synch_base, - xnsched_current_thread()) != NULL)) + xnsched_current_thread()))) xnsched_run(); } EXPORT_SYMBOL_GPL(rtdm_mutex_unlock); diff --git a/kernel/cobalt/synch.c b/kernel/cobalt/synch.c index 976261d..d8b83d9 100644 --- a/kernel/cobalt/synch.c +++ b/kernel/cobalt/synch.c @@ -843,8 +843,8 @@ static inline void clear_pp_boost(struct xnsynch *synch, drop_booster(synch, owner); } -static struct xnthread *transfer_ownership(struct xnsynch *synch, - struct xnthread *lastowner) +static bool transfer_ownership(struct xnsynch *synch, + struct xnthread *lastowner) { /* nklock held, irqs off */ struct xnthread *nextowner; xnhandle_t nextownerh; @@ -859,7 +859,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, if (list_empty(&synch->pendq)) { synch->owner = NULL; atomic_set(lockp, XN_NO_HANDLE); - return NULL; + return false; } nextowner = list_first_entry(&synch->pendq, struct xnthread, plink); @@ -879,11 +879,11 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, atomic_set(lockp, nextownerh); - return nextowner; + return true; } /** - * @fn struct xnthread *xnsynch_release(struct xnsynch *synch, struct xnthread *curr) + * @fn bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) * @brief Release a resource and pass it to the next waiting thread. * * This service releases the ownership of the given synchronization @@ -900,7 +900,7 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * @param curr The descriptor address of the current thread, which * must own the object at the time of calling. * - * @return The descriptor address of the unblocked thread. + * @return True if a reschedule is required. * * @sideeffect * @@ -913,10 +913,9 @@ static struct xnthread *transfer_ownership(struct xnsynch *synch, * * @coretags{primary-only, might-switch} */ -struct xnthread *xnsynch_release(struct xnsynch *synch, - struct xnthread *curr) +bool xnsynch_release(struct xnsynch *synch, struct xnthread *curr) { - struct xnthread *nextowner = NULL; + bool need_resched = false; xnhandle_t currh, h; atomic_t *lockp; spl_t s; @@ -926,7 +925,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, trace_cobalt_synch_release(synch); if (xnthread_put_resource(curr)) - return NULL; + return false; lockp = xnsynch_fastlock(synch); currh = curr->handle; @@ -946,7 +945,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, h = atomic_cmpxchg(lockp, currh, XN_NO_HANDLE); if ((h & ~XNSYNCH_FLCEIL) != currh) /* FLCLAIM set, synch is contended. */ - nextowner = transfer_ownership(synch, curr); + need_resched = transfer_ownership(synch, curr); else if (h != currh) /* FLCEIL set, FLCLAIM clear. */ atomic_set(lockp, XN_NO_HANDLE); @@ -955,7 +954,7 @@ struct xnthread *xnsynch_release(struct xnsynch *synch, xnlock_put_irqrestore(&nklock, s); - return nextowner; + return need_resched; } EXPORT_SYMBOL_GPL(xnsynch_release); _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org https://xenomai.org/mailman/listinfo/xenomai-git