Added chMtxUnlockAllS().

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8927 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2016-02-23 09:11:43 +00:00
parent 7b08ab4ae5
commit 45e44e7328
2 changed files with 40 additions and 0 deletions

View File

@ -108,6 +108,7 @@ extern "C" {
void chMtxUnlock(mutex_t *mp);
void chMtxUnlockS(mutex_t *mp);
void chMtxUnlockAll(void);
void chMtxUnlockAllS(void);
#ifdef __cplusplus
}
#endif

View File

@ -471,6 +471,45 @@ void chMtxUnlockS(mutex_t *mp) {
#endif
}
/**
* @brief Unlocks all mutexes owned by the invoking thread.
* @post The stack of owned mutexes is emptied and all the found
* mutexes are unlocked.
* @post This function does not reschedule so a call to a rescheduling
* function must be performed before unlocking the kernel.
* @note This function is <b>MUCH MORE</b> efficient than releasing the
* mutexes one by one and not just because the call overhead,
* this function does not have any overhead related to the priority
* inheritance mechanism.
*
* @sclass
*/
void chMtxUnlockAllS(void) {
thread_t *ctp = currp;
while (ctp->mtxlist != NULL) {
mutex_t *mp = ctp->mtxlist;
ctp->mtxlist = mp->next;
if (chMtxQueueNotEmptyS(mp)) {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->cnt = (cnt_t)1;
#endif
thread_t *tp = queue_fifo_remove(&mp->queue);
mp->owner = tp;
mp->next = tp->mtxlist;
tp->mtxlist = mp;
(void) chSchReadyI(tp);
}
else {
#if CH_CFG_USE_MUTEXES_RECURSIVE == TRUE
mp->cnt = (cnt_t)0;
#endif
mp->owner = NULL;
}
}
ctp->prio = ctp->realprio;
}
/**
* @brief Unlocks all mutexes owned by the invoking thread.
* @post The stack of owned mutexes is emptied and all the found