Events subsystem optimizations.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1538 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
ea02b6612f
commit
11a6a2bf64
|
@ -217,17 +217,18 @@ void chEvtDispatch(const evhandler_t handlers[], eventmask_t mask) {
|
|||
* an higher priority.
|
||||
*/
|
||||
eventmask_t chEvtWaitOne(eventmask_t ewmask) {
|
||||
Thread *ctp = currp;
|
||||
eventmask_t m;
|
||||
|
||||
chSysLock();
|
||||
|
||||
if ((m = (currp->p_epending & ewmask)) == 0) {
|
||||
currp->p_u.ewmask = ewmask;
|
||||
if ((m = (ctp->p_epending & ewmask)) == 0) {
|
||||
ctp->p_u.ewmask = ewmask;
|
||||
chSchGoSleepS(THD_STATE_WTOREVT);
|
||||
m = currp->p_epending & ewmask;
|
||||
m = ctp->p_epending & ewmask;
|
||||
}
|
||||
m &= -m;
|
||||
currp->p_epending &= ~m;
|
||||
ctp->p_epending &= ~m;
|
||||
|
||||
chSysUnlock();
|
||||
return m;
|
||||
|
@ -243,16 +244,17 @@ eventmask_t chEvtWaitOne(eventmask_t ewmask) {
|
|||
* @return The mask of the served and cleared events.
|
||||
*/
|
||||
eventmask_t chEvtWaitAny(eventmask_t ewmask) {
|
||||
Thread *ctp = currp;
|
||||
eventmask_t m;
|
||||
|
||||
chSysLock();
|
||||
|
||||
if ((m = (currp->p_epending & ewmask)) == 0) {
|
||||
currp->p_u.ewmask = ewmask;
|
||||
if ((m = (ctp->p_epending & ewmask)) == 0) {
|
||||
ctp->p_u.ewmask = ewmask;
|
||||
chSchGoSleepS(THD_STATE_WTOREVT);
|
||||
m = currp->p_epending & ewmask;
|
||||
m = ctp->p_epending & ewmask;
|
||||
}
|
||||
currp->p_epending &= ~m;
|
||||
ctp->p_epending &= ~m;
|
||||
|
||||
chSysUnlock();
|
||||
return m;
|
||||
|
@ -267,14 +269,15 @@ eventmask_t chEvtWaitAny(eventmask_t ewmask) {
|
|||
* @return The mask of the served and cleared events.
|
||||
*/
|
||||
eventmask_t chEvtWaitAll(eventmask_t ewmask) {
|
||||
Thread *ctp = currp;
|
||||
|
||||
chSysLock();
|
||||
|
||||
if ((currp->p_epending & ewmask) != ewmask) {
|
||||
currp->p_u.ewmask = ewmask;
|
||||
if ((ctp->p_epending & ewmask) != ewmask) {
|
||||
ctp->p_u.ewmask = ewmask;
|
||||
chSchGoSleepS(THD_STATE_WTANDEVT);
|
||||
}
|
||||
currp->p_epending &= ~ewmask;
|
||||
ctp->p_epending &= ~ewmask;
|
||||
|
||||
chSysUnlock();
|
||||
return ewmask;
|
||||
|
@ -303,20 +306,21 @@ eventmask_t chEvtWaitAll(eventmask_t ewmask) {
|
|||
* an higher priority.
|
||||
*/
|
||||
eventmask_t chEvtWaitOneTimeout(eventmask_t ewmask, systime_t time) {
|
||||
Thread *ctp = currp;
|
||||
eventmask_t m;
|
||||
|
||||
chSysLock();
|
||||
|
||||
if ((m = (currp->p_epending & ewmask)) == 0) {
|
||||
if ((m = (ctp->p_epending & ewmask)) == 0) {
|
||||
if (TIME_IMMEDIATE == time)
|
||||
return (eventmask_t)0;
|
||||
currp->p_u.ewmask = ewmask;
|
||||
ctp->p_u.ewmask = ewmask;
|
||||
if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK)
|
||||
return (eventmask_t)0;
|
||||
m = currp->p_epending & ewmask;
|
||||
m = ctp->p_epending & ewmask;
|
||||
}
|
||||
m &= -m;
|
||||
currp->p_epending &= ~m;
|
||||
ctp->p_epending &= ~m;
|
||||
|
||||
chSysUnlock();
|
||||
return m;
|
||||
|
@ -339,19 +343,20 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t ewmask, systime_t time) {
|
|||
* @retval 0 if the specified timeout expired.
|
||||
*/
|
||||
eventmask_t chEvtWaitAnyTimeout(eventmask_t ewmask, systime_t time) {
|
||||
Thread *ctp = currp;
|
||||
eventmask_t m;
|
||||
|
||||
chSysLock();
|
||||
|
||||
if ((m = (currp->p_epending & ewmask)) == 0) {
|
||||
if ((m = (ctp->p_epending & ewmask)) == 0) {
|
||||
if (TIME_IMMEDIATE == time)
|
||||
return (eventmask_t)0;
|
||||
currp->p_u.ewmask = ewmask;
|
||||
ctp->p_u.ewmask = ewmask;
|
||||
if (chSchGoSleepTimeoutS(THD_STATE_WTOREVT, time) < RDY_OK)
|
||||
return (eventmask_t)0;
|
||||
m = currp->p_epending & ewmask;
|
||||
m = ctp->p_epending & ewmask;
|
||||
}
|
||||
currp->p_epending &= ~m;
|
||||
ctp->p_epending &= ~m;
|
||||
|
||||
chSysUnlock();
|
||||
return m;
|
||||
|
@ -372,17 +377,18 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t ewmask, systime_t time) {
|
|||
* @retval 0 if the specified timeout expired.
|
||||
*/
|
||||
eventmask_t chEvtWaitAllTimeout(eventmask_t ewmask, systime_t time) {
|
||||
Thread *ctp = currp;
|
||||
|
||||
chSysLock();
|
||||
|
||||
if ((currp->p_epending & ewmask) != ewmask) {
|
||||
if ((ctp->p_epending & ewmask) != ewmask) {
|
||||
if (TIME_IMMEDIATE == time)
|
||||
return (eventmask_t)0;
|
||||
currp->p_u.ewmask = ewmask;
|
||||
ctp->p_u.ewmask = ewmask;
|
||||
if (chSchGoSleepTimeoutS(THD_STATE_WTANDEVT, time) < RDY_OK)
|
||||
return (eventmask_t)0;
|
||||
}
|
||||
currp->p_epending &= ~ewmask;
|
||||
ctp->p_epending &= ~ewmask;
|
||||
|
||||
chSysUnlock();
|
||||
return ewmask;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
- CHANGE: Removed the unnamed union from the Thread structure some compilers
|
||||
do not support this non standard construct.
|
||||
- CHANGE: Modified the thread-related constant macros to have a THD_ prefix.
|
||||
- OPT: Speed/size optimization to the events subsystem.
|
||||
- OPT: Speed/size optimization to the mutexes subsystem.
|
||||
- OPT: Speed/size optimization to the condvars subsystem.
|
||||
- OPT: Speed/size optimization to the synchronous messages subsystem.
|
||||
|
|
Loading…
Reference in New Issue