diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-01-21 19:57:30 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-01-21 19:57:30 +0000 |
commit | 11a6a2bf6476beda7a3a6d8504aa74c03c3b9731 (patch) | |
tree | 7a0d5b60c4577c0d2f861c4afa9fc1df4a8e887c /os/kernel/src | |
parent | ea02b6612f7f377f77cbdebe29d0d52f30e5fdeb (diff) | |
download | ChibiOS-11a6a2bf6476beda7a3a6d8504aa74c03c3b9731.tar.gz ChibiOS-11a6a2bf6476beda7a3a6d8504aa74c03c3b9731.tar.bz2 ChibiOS-11a6a2bf6476beda7a3a6d8504aa74c03c3b9731.zip |
Events subsystem optimizations.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1538 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src')
-rw-r--r-- | os/kernel/src/chevents.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/os/kernel/src/chevents.c b/os/kernel/src/chevents.c index 580b0aea9..9da61adaf 100644 --- a/os/kernel/src/chevents.c +++ b/os/kernel/src/chevents.c @@ -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;
|