diff --git a/readme.txt b/readme.txt index 537642ebb..00a8baabe 100644 --- a/readme.txt +++ b/readme.txt @@ -65,6 +65,8 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not tested on hardware yet. *** 0.6.1 *** - Removed some redundant checks from the scheduler code: improved threads flyback time. +- Manual optimization in chSchReadyI(), it seems GCC is missing some obvious + code optimizations here. Both code size and speed improved. - Removed the -falign-functions=16 option from the AT91SAM7X demo makefiles, the Atmel chip does not require it, the option is still present on the LPC21xx demos. This saves significant ROM space. diff --git a/src/chschd.c b/src/chschd.c index b7f52c96d..7c45e009e 100644 --- a/src/chschd.c +++ b/src/chschd.c @@ -24,7 +24,7 @@ #include -/** @cond never*/ +/** @cond never */ ReadyList rlist; /** @endcond */ @@ -58,10 +58,11 @@ INLINE void chSchReadyI(Thread *tp, msg_t msg) { #else void chSchReadyI(Thread *tp, msg_t msg) { #endif - Thread *cp = rlist.r_queue.p_next; + Thread *cp; tp->p_state = PRREADY; tp->p_rdymsg = msg; + cp = rlist.r_queue.p_next; while (cp->p_prio >= tp->p_prio) cp = cp->p_next; /* Insertion on p_prev.*/ diff --git a/src/include/threads.h b/src/include/threads.h index 11674b322..d9bb467b9 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -107,30 +107,28 @@ struct Thread { #endif }; -/** Thread state: Reserved.*/ -#define PRFREE 0 +/** Thread state: Thread in the ready list.*/ +#define PRREADY 0 /** Thread state: Current.*/ #define PRCURR 1 -/** Thread state: Thread in the ready list.*/ -#define PRREADY 2 /** Thread state: Thread created in suspended state.*/ -#define PRSUSPENDED 3 +#define PRSUSPENDED 2 /** Thread state: Waiting on a semaphore.*/ -#define PRWTSEM 4 +#define PRWTSEM 3 /** Thread state: Waiting on a mutex.*/ -#define PRWTMTX 5 +#define PRWTMTX 4 /** Thread state: Waiting in \p chThdSleep() or \p chThdSleepUntil().*/ -#define PRSLEEP 6 +#define PRSLEEP 5 /** Thread state: Waiting in \p chThdWait().*/ -#define PRWAIT 7 +#define PRWAIT 6 /** Thread state: Waiting in \p chEvtWait().*/ -#define PRWTEVENT 8 +#define PRWTEVENT 7 /** Thread state: Waiting in \p chMsgSend().*/ -#define PRSNDMSG 9 +#define PRSNDMSG 8 /** Thread state: Waiting in \p chMsgWait().*/ -#define PRWTMSG 10 +#define PRWTMSG 9 /** Thread state: After termination.*/ -#define PREXIT 11 +#define PREXIT 10 #ifdef CH_USE_TERMINATE /** Thread option: Termination requested flag.*/