From 890c5532da783e8d58cfbf28822bcedaa8a0c61d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 14 Nov 2007 16:32:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@90 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/chmsg.c | 2 +- src/chschd.c | 24 ++++++++++++++---------- src/include/threads.h | 3 +++ 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/chmsg.c b/src/chmsg.c index 5ea3f9821..0f24b24aa 100644 --- a/src/chmsg.c +++ b/src/chmsg.c @@ -153,7 +153,7 @@ t_msg chMsgWait(void) { * @return the pointer to the message structure. Note, it is always the * message associated to the thread on the top of the messages queue. * If the queue is empty then \p NULL is returned. - * @note You can assume that the data contained in the message is stable until + * @note You can assume that the data pointed by the message is stable until * you invoke \p chMsgRelease() because the sending thread is * suspended until then. Always remember that the message data is not * copied between the sender and the receiver, just a pointer is passed. diff --git a/src/chschd.c b/src/chschd.c index c88a63ead..a3763cd38 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -81,7 +81,11 @@ Thread *chSchReadyI(Thread *tp) { * Switches to the next thread in the ready list, the ready list is assumed * to contain at least a thread. */ +#ifdef CH_OPTIMIZE_SPEED +static INLINE void nextready(void) { +#else static void nextready(void) { +#endif Thread *otp = currp; (currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR; @@ -111,27 +115,27 @@ void chSchGoSleepS(t_tstate newstate) { * Wakeups a thread, the thread is inserted into the ready list or made * running directly depending on its relative priority compared to the current * thread. - * @param tp the Thread to be made ready + * @param ntp the Thread to be made ready * @param msg wakeup message to the awakened thread * @note The function must be called in the system mutex zone. * @note The function is not meant to be used in the user code directly. * @note It is equivalent to a \p chSchReadyI() followed by a * \p chSchRescheduleI() but much more efficient. */ -void chSchWakeupS(Thread *tp, t_msg msg) { - Thread *ctp = currp; +void chSchWakeupS(Thread *ntp, t_msg msg) { - if (tp->p_prio <= ctp->p_prio) - chSchReadyI(tp)->p_rdymsg = msg; + if (ntp->p_prio <= currp->p_prio) + chSchReadyI(ntp)->p_rdymsg = msg; else { - chSchReadyI(ctp); - (currp = tp)->p_state = PRCURR; - tp->p_rdymsg = msg; + Thread *otp = currp; + chSchReadyI(otp); + (currp = ntp)->p_state = PRCURR; + ntp->p_rdymsg = msg; preempt = CH_TIME_QUANTUM; #ifdef CH_USE_DEBUG - chDbgTrace(ctp, tp); + chDbgTrace(otp, ntp); #endif - chSysSwitchI(&ctp->p_ctx, &tp->p_ctx); + chSysSwitchI(&otp->p_ctx, &ntp->p_ctx); } } diff --git a/src/include/threads.h b/src/include/threads.h index e4cd8376e..ee00039b3 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -178,6 +178,9 @@ extern "C" { /** Returns the pointer to the \p Thread currently in execution.*/ #define chThdSelf() currp +/** Returns the thread priority.*/ +#define chThdGetPriority() (currp->p_prio) + /** Returns the pointer to the \p Thread local storage area, if any.*/ #define chThdLS() (void *)(currp + 1) -- cgit v1.2.3