From 38e0ede2ba22ce081f862d236829916949cc1447 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 14 Aug 2013 15:25:23 +0000 Subject: Small optimizations. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6147 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/src/chcond.c | 7 +++++-- os/rt/src/chevents.c | 6 ++++-- os/rt/src/chschd.c | 11 +++++++---- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'os/rt/src') 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); -- cgit v1.2.3