diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-09-11 15:03:25 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-09-11 15:03:25 +0000 |
commit | a474010e54534785366d1924554f5452725499b0 (patch) | |
tree | 30084f68f1500f1a04d31472f8c75c9bf74b3e1d /src/chmtx.c | |
parent | fceb645e35ab2708ec6e2c6ba944d328024ebecf (diff) | |
download | ChibiOS-a474010e54534785366d1924554f5452725499b0.tar.gz ChibiOS-a474010e54534785366d1924554f5452725499b0.tar.bz2 ChibiOS-a474010e54534785366d1924554f5452725499b0.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@430 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chmtx.c')
-rw-r--r-- | src/chmtx.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/chmtx.c b/src/chmtx.c index 7ab8ae613..f5dbaca43 100644 --- a/src/chmtx.c +++ b/src/chmtx.c @@ -149,8 +149,8 @@ bool_t chMtxTryLockS(Mutex *mp) { /** * Unlocks the next owned mutex in reverse lock order. */ -void chMtxUnlock(void) { - Mutex *mp; +Mutex *chMtxUnlock(void) { + Mutex *ump, *mp; chSysLock(); @@ -158,16 +158,16 @@ void chMtxUnlock(void) { "chmtx.c, chMtxUnlock()"); /* remove the top Mutex from the Threads's owned mutexes list */ - mp = currp->p_mtxlist; - currp->p_mtxlist = mp->m_next; + ump = currp->p_mtxlist; + currp->p_mtxlist = ump->m_next; /* mark the Mutex as not owned */ - mp->m_owner = NULL; + ump->m_owner = NULL; /* * If a thread is waiting on the mutex then the hard part begins. */ - if (chMtxQueueNotEmptyS(mp)) { + if (chMtxQueueNotEmptyS(ump)) { /* get the highest priority thread waiting for the unlocked mutex */ - Thread *tp = fifo_remove(&mp->m_queue); + Thread *tp = fifo_remove(&ump->m_queue); /* * Recalculates the optimal thread priority by scanning the owned mutexes list. */ @@ -187,6 +187,7 @@ void chMtxUnlock(void) { chSchWakeupS(tp, RDY_OK); } chSysUnlock(); + return ump; } /** @@ -195,8 +196,8 @@ void chMtxUnlock(void) { * block. * @note This function does not reschedule internally. */ -void chMtxUnlockS(void) { - Mutex *mp; +Mutex *chMtxUnlockS(void) { + Mutex *ump, *mp; chDbgAssert((currp->p_mtxlist != NULL) && (currp->p_mtxlist->m_owner == currp), "chmtx.c, chMtxUnlockS()"); @@ -204,14 +205,14 @@ void chMtxUnlockS(void) { /* * Removes the top Mutex from the owned mutexes list and marks it as not owned. */ - mp = currp->p_mtxlist; - currp->p_mtxlist = mp->m_next; - mp->m_owner = NULL; + ump = currp->p_mtxlist; + currp->p_mtxlist = ump->m_next; + ump->m_owner = NULL; /* * If a thread is waiting on the mutex then the hard part begins. */ - if (chMtxQueueNotEmptyS(mp)) { - Thread *tp = fifo_remove(&mp->m_queue); + if (chMtxQueueNotEmptyS(ump)) { + Thread *tp = fifo_remove(&ump->m_queue); /* * Recalculates the optimal thread priority by scanning the owned mutexes list. */ @@ -225,6 +226,7 @@ void chMtxUnlockS(void) { currp->p_prio = newprio; chSchReadyI(tp); } + return ump; } /** |