git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1534 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2010-01-20 20:45:56 +00:00
parent 14005a2ffe
commit 85016e2a26
3 changed files with 11 additions and 17 deletions

View File

@ -48,9 +48,9 @@ msg_t chMsgSend(Thread *tp, msg_t msg) {
chDbgCheck(tp != NULL, "chMsgSend"); chDbgCheck(tp != NULL, "chMsgSend");
chSysLock(); chSysLock();
msg_insert(currp, &tp->p_msgqueue);
currp->p_msg = msg; currp->p_msg = msg;
currp->p_u.wtobjp = tp; currp->p_u.wtobjp = &tp->p_msgqueue;
msg_insert(currp, &tp->p_msgqueue);
if (tp->p_state == THD_STATE_WTMSG) if (tp->p_state == THD_STATE_WTMSG)
chSchReadyI(tp); chSchReadyI(tp);
chSchGoSleepS(THD_STATE_SNDMSG); chSchGoSleepS(THD_STATE_SNDMSG);

View File

@ -77,37 +77,30 @@ void chMtxLockS(Mutex *mp) {
* of the running thread requesting the mutex. * of the running thread requesting the mutex.
*/ */
Thread *tp = mp->m_owner; Thread *tp = mp->m_owner;
/* {tp is the thread currently owning the mutex} */ /* Does the running thread have higher priority than the mutex
/* Has the running thread higher priority than tp? */ * ownning thread? */
while (tp->p_prio < currp->p_prio) { while (tp->p_prio < currp->p_prio) {
/* Make priority of thread tp match the running thread's priority.*/ /* Make priority of thread tp match the running thread's priority.*/
tp->p_prio = currp->p_prio; tp->p_prio = currp->p_prio;
/* /* The following states need priority queues reordering.*/
* The following states need priority queues reordering.
*/
switch (tp->p_state) { switch (tp->p_state) {
case THD_STATE_WTMTX: case THD_STATE_WTMTX:
/* Re-enqueues tp with its new priority on the mutex wait queue.*/ /* Re-enqueues the mutex owner with its new priority.*/
prio_insert(dequeue(tp), (ThreadsQueue *)tp->p_u.wtobjp); prio_insert(dequeue(tp), (ThreadsQueue *)tp->p_u.wtobjp);
/* Boost the owner of this mutex if needed.*/
tp = ((Mutex *)tp->p_u.wtobjp)->m_owner; tp = ((Mutex *)tp->p_u.wtobjp)->m_owner;
continue; continue;
#if CH_USE_CONDVARS | CH_USE_SEMAPHORES_PRIORITY | CH_USE_MESSAGES_PRIORITY
#if CH_USE_CONDVARS #if CH_USE_CONDVARS
case THD_STATE_WTCOND: case THD_STATE_WTCOND:
/* Re-enqueues tp with its new priority on the condvar queue.*/
prio_insert(dequeue(tp), (ThreadsQueue *)tp->p_u.wtobjp);
break;
#endif #endif
#if CH_USE_SEMAPHORES_PRIORITY #if CH_USE_SEMAPHORES_PRIORITY
case THD_STATE_WTSEM: case THD_STATE_WTSEM:
/* Re-enqueues tp with its new priority on the semaphore queue.*/
prio_insert(dequeue(tp), (ThreadsQueue *)tp->p_u.wtobjp);
break;
#endif #endif
#if CH_USE_MESSAGES_PRIORITY #if CH_USE_MESSAGES_PRIORITY
case THD_STATE_SNDMSG: case THD_STATE_SNDMSG:
/* Re-enqueues tp with its new priority on the server thread queue.*/ #endif
prio_insert(dequeue(tp), &((Thread *)tp->p_u.wtobjp)->p_msgqueue); /* Re-enqueues tp with its new priority on the queue.*/
prio_insert(dequeue(tp), (ThreadsQueue *)tp->p_u.wtobjp);
break; break;
#endif #endif
case THD_STATE_READY: case THD_STATE_READY:

View File

@ -59,6 +59,7 @@
- CHANGE: Removed the unnamed union from the Thread structure some compilers - CHANGE: Removed the unnamed union from the Thread structure some compilers
do not support this non standard construct. do not support this non standard construct.
- CHANGE: Modified the thread-related constant macros to have a THD_ prefix. - CHANGE: Modified the thread-related constant macros to have a THD_ prefix.
- OPT: Optimizations to the priority inheritance code.
*** 1.3.8 *** *** 1.3.8 ***
- FIX: Fixed dequeuing in lifo_remove() function (bug 2928142). - FIX: Fixed dequeuing in lifo_remove() function (bug 2928142).