diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-08-14 15:25:23 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-08-14 15:25:23 +0000 |
commit | 38e0ede2ba22ce081f862d236829916949cc1447 (patch) | |
tree | 0b648e8a47f9cd790624e3a8f7daced850131c6f /os | |
parent | 782415628b7da8871b1ab0d6adfcd0ec325cf485 (diff) | |
download | ChibiOS-38e0ede2ba22ce081f862d236829916949cc1447.tar.gz ChibiOS-38e0ede2ba22ce081f862d236829916949cc1447.tar.bz2 ChibiOS-38e0ede2ba22ce081f862d236829916949cc1447.zip |
Small optimizations.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6147 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/rt/src/chcond.c | 7 | ||||
-rw-r--r-- | os/rt/src/chevents.c | 6 | ||||
-rw-r--r-- | os/rt/src/chschd.c | 11 |
3 files changed, 16 insertions, 8 deletions
diff --git a/os/rt/src/chcond.c b/os/rt/src/chcond.c index 94fd8e81c..9ea003c7b 100644 --- a/os/rt/src/chcond.c +++ b/os/rt/src/chcond.c @@ -113,8 +113,11 @@ void chCondSignalI(condition_variable_t *cp) { chDbgCheckClassI();
chDbgCheck(cp != NULL);
- if (queue_notempty(&cp->c_queue))
- chSchReadyI(queue_fifo_remove(&cp->c_queue))->p_u.rdymsg = RDY_OK;
+ if (queue_notempty(&cp->c_queue)) {
+ thread_t *tp = queue_fifo_remove(&cp->c_queue);
+ tp->p_u.rdymsg = RDY_OK;
+ chSchReadyI(tp);
+ }
}
/**
diff --git a/os/rt/src/chevents.c b/os/rt/src/chevents.c index 04b0e6fb8..ad59f51c0 100644 --- a/os/rt/src/chevents.c +++ b/os/rt/src/chevents.c @@ -278,8 +278,10 @@ void chEvtSignalI(thread_t *tp, eventmask_t mask) { if (((tp->p_state == CH_STATE_WTOREVT) &&
((tp->p_epending & tp->p_u.ewmask) != 0)) ||
((tp->p_state == CH_STATE_WTANDEVT) &&
- ((tp->p_epending & tp->p_u.ewmask) == tp->p_u.ewmask)))
- chSchReadyI(tp)->p_u.rdymsg = RDY_OK;
+ ((tp->p_epending & tp->p_u.ewmask) == tp->p_u.ewmask))) {
+ tp->p_u.rdymsg = RDY_OK;
+ chSchReadyI(tp);
+ }
}
/**
diff --git a/os/rt/src/chschd.c b/os/rt/src/chschd.c index 615008589..ac77139ae 100644 --- a/os/rt/src/chschd.c +++ b/os/rt/src/chschd.c @@ -87,8 +87,7 @@ thread_t *chSchReadyI(thread_t *tp) { thread_t *cp;
chDbgCheckClassI();
-
- /* Integrity checks.*/
+ chDbgCheck(tp != NULL);
chDbgAssert((tp->p_state != CH_STATE_READY) &&
(tp->p_state != CH_STATE_FINAL),
"invalid state");
@@ -216,7 +215,7 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) { * priority.
*
* @param[in] ntp the thread to be made ready
- * @param[in] msg message to the awakened thread
+ * @param[in] msg the wakeup message
*
* @sclass
*/
@@ -224,13 +223,17 @@ void chSchWakeupS(thread_t *ntp, msg_t msg) { chDbgCheckClassS();
+ /* Storing the message to be retrieved by the target thread when it will
+ restart execution.*/
ntp->p_u.rdymsg = msg;
+
/* If the waken thread has a not-greater priority than the current
one then it is just inserted in the ready list else it made
running immediately and the invoking thread goes in the ready
list instead.*/
- if (ntp->p_prio <= currp->p_prio)
+ if (ntp->p_prio <= currp->p_prio) {
chSchReadyI(ntp);
+ }
else {
thread_t *otp = chSchReadyI(currp);
setcurrp(ntp);
|