git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1749 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2010-03-18 16:01:11 +00:00
parent 7ae3e3227e
commit cf1b70f486
8 changed files with 45 additions and 32 deletions

View File

@ -20,7 +20,7 @@
/** /**
* @page article_atomic Invoking multiple primitives as a single atomic operation * @page article_atomic Invoking multiple primitives as a single atomic operation
* It is often necessary to invoke multiple operations involving a * It is often necessary to invoke multiple operations involving a
* reschedulation as a single atomic operation.<br> * reschedule as a single atomic operation.<br>
* ChibiOS/RT already implements APIs that perform complex operations, as * ChibiOS/RT already implements APIs that perform complex operations, as
* example the API @p chSemSignalWait() performs two operations atomically.<br> * example the API @p chSemSignalWait() performs two operations atomically.<br>
* If more complex operations are required in your application then it is * If more complex operations are required in your application then it is
@ -36,9 +36,9 @@
chSysUnlock(); chSysUnlock();
* @endcode * @endcode
* The above example performs a signal operation on two semaphores, unlocks the * The above example performs a signal operation on two semaphores, unlocks the
* last aquired mutex and finally performs a reschedulation. All the operations * last acquired mutex and finally performs a reschedule. All the operations
* are performed atomically.<br> * are performed atomically.<br>
* An hypotetical @p chSemSignalSignalWait() operation could be implemented as * An hypothetical @p chSemSignalSignalWait() operation could be implemented as
* follow: * follow:
* @code * @code
chSysLock(); chSysLock();
@ -53,5 +53,5 @@
* In general multiple @ref I-Class and (non rescheduling) @ref S-Class APIs * In general multiple @ref I-Class and (non rescheduling) @ref S-Class APIs
* can be included and the block is terminated by a rescheduling @ref S-Class * can be included and the block is terminated by a rescheduling @ref S-Class
* API. An extra @p chSchRescheduleS() can be present at the very end of the * API. An extra @p chSchRescheduleS() can be present at the very end of the
* block, it only reschedules if a reschedulation is still required. * block, it only reschedules if a reschedule is still required.
*/ */

View File

@ -105,14 +105,27 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE);
extern "C" { extern "C" {
#endif #endif
void scheduler_init(void); void scheduler_init(void);
#if !defined(PORT_OPTIMIZED_READYI)
Thread *chSchReadyI(Thread *tp); Thread *chSchReadyI(Thread *tp);
#endif
#if !defined(PORT_OPTIMIZED_GOSLEEPS)
void chSchGoSleepS(tstate_t newstate); void chSchGoSleepS(tstate_t newstate);
#endif
#if !defined(PORT_OPTIMIZED_GOSLEEPTIMEOUTS)
msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time); msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time);
#endif
#if !defined(PORT_OPTIMIZED_WAKEUPS)
void chSchWakeupS(Thread *tp, msg_t msg); void chSchWakeupS(Thread *tp, msg_t msg);
#endif
#if !defined(PORT_OPTIMIZED_DORESCHEDULEI)
void chSchDoRescheduleI(void); void chSchDoRescheduleI(void);
#endif
#if !defined(PORT_OPTIMIZED_RESCHEDULES)
void chSchRescheduleS(void); void chSchRescheduleS(void);
#endif
#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI)
bool_t chSchIsRescRequiredExI(void); bool_t chSchIsRescRequiredExI(void);
void chSchDoYieldS(void); #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -148,7 +148,7 @@
/** /**
* @brief IRQ handler exit code. * @brief IRQ handler exit code.
* @note Usually IRQ handlers function are also declared naked. * @note Usually IRQ handlers function are also declared naked.
* @note This macro usually performs the final reschedulation by using * @note This macro usually performs the final reschedule by using
* @p chSchRescRequiredI() and @p chSchDoRescheduleI(). * @p chSchRescRequiredI() and @p chSchDoRescheduleI().
*/ */
#define CH_IRQ_EPILOGUE() PORT_IRQ_EPILOGUE() #define CH_IRQ_EPILOGUE() PORT_IRQ_EPILOGUE()

View File

@ -105,23 +105,21 @@ void chSchGoSleepS(tstate_t newstate) {
} }
#endif /* !defined(PORT_OPTIMIZED_GOSLEEPS) */ #endif /* !defined(PORT_OPTIMIZED_GOSLEEPS) */
#if !defined(PORT_OPTIMIZED_GOSLEEPTIMEOUTS) || defined(__DOXYGEN__)
/* /*
* Timeout wakeup callback. * Timeout wakeup callback.
*/ */
static void wakeup(void *p) { static void wakeup(void *p) {
Thread *tp = (Thread *)p; Thread *tp = (Thread *)p;
#if CH_USE_SEMAPHORES || CH_USE_MUTEXES || CH_USE_CONDVARS #if CH_USE_SEMAPHORES || (CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT)
switch (tp->p_state) { switch (tp->p_state) {
#if CH_USE_SEMAPHORES #if CH_USE_SEMAPHORES
case THD_STATE_WTSEM: case THD_STATE_WTSEM:
chSemFastSignalI((Semaphore *)tp->p_u.wtobjp); chSemFastSignalI((Semaphore *)tp->p_u.wtobjp);
/* Falls into, intentional. */ /* Falls into, intentional. */
#endif #endif
#if CH_USE_MUTEXES #if CH_USE_CONDVARS && CH_USE_CONDVARS_TIMEOUT
case THD_STATE_WTMTX:
#endif
#if CH_USE_CONDVARS
case THD_STATE_WTCOND: case THD_STATE_WTCOND:
#endif #endif
/* States requiring dequeuing.*/ /* States requiring dequeuing.*/
@ -166,6 +164,7 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
chSchGoSleepS(newstate); chSchGoSleepS(newstate);
return currp->p_u.rdymsg; return currp->p_u.rdymsg;
} }
#endif /* !defined(PORT_OPTIMIZED_GOSLEEPTIMEOUTS) */
/** /**
* @brief Wakes up a thread. * @brief Wakes up a thread.
@ -191,8 +190,7 @@ void chSchWakeupS(Thread *ntp, msg_t msg) {
if (ntp->p_prio <= currp->p_prio) if (ntp->p_prio <= currp->p_prio)
chSchReadyI(ntp); chSchReadyI(ntp);
else { else {
Thread *otp = currp; Thread *otp = chSchReadyI(currp);
chSchReadyI(otp);
#if CH_TIME_QUANTUM > 0 #if CH_TIME_QUANTUM > 0
rlist.r_preempt = CH_TIME_QUANTUM; rlist.r_preempt = CH_TIME_QUANTUM;
#endif #endif
@ -225,7 +223,7 @@ void chSchDoRescheduleI(void) {
#endif /* !defined(PORT_OPTIMIZED_DORESCHEDULEI) */ #endif /* !defined(PORT_OPTIMIZED_DORESCHEDULEI) */
/** /**
* @brief Performs a reschedulation if a higher priority thread is runnable. * @brief Performs a reschedule if a higher priority thread is runnable.
* @details If a thread with a higher priority than the current thread is in * @details If a thread with a higher priority than the current thread is in
* the ready list then make the higher priority thread running. * the ready list then make the higher priority thread running.
*/ */
@ -238,14 +236,14 @@ void chSchRescheduleS(void) {
#endif /* !defined(PORT_OPTIMIZED_RESCHEDULES) */ #endif /* !defined(PORT_OPTIMIZED_RESCHEDULES) */
/** /**
* @brief Evaluates if a reschedulation is required. * @brief Evaluates if a reschedule is required.
* @details The decision is taken by comparing the relative priorities and * @details The decision is taken by comparing the relative priorities and
* depending on the state of the round robin timeout counter. * depending on the state of the round robin timeout counter.
* @note This function is meant to be used in the timer interrupt handler * @note This function is meant to be used in the timer interrupt handler
* where @p chVTDoTickI() is invoked. * where @p chVTDoTickI() is invoked.
* *
* @retval TRUE if there is a thread that should go in running state. * @retval TRUE if there is a thread that should go in running state.
* @retval FALSE if a reschedulation is not required. * @retval FALSE if a reschedule is not required.
*/ */
#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) || defined(__DOXYGEN__)
bool_t chSchIsRescRequiredExI(void) { bool_t chSchIsRescRequiredExI(void) {

View File

@ -23,9 +23,10 @@
* @addtogroup ARM7_CORE * @addtogroup ARM7_CORE
* @{ * @{
*/ */
/** @cond never */
#include <chconf.h> #include "chconf.h"
#if !defined(__DOXYGEN__)
.set MODE_USR, 0x10 .set MODE_USR, 0x10
.set MODE_FIQ, 0x11 .set MODE_FIQ, 0x11
@ -230,5 +231,6 @@ jmpr4:
bx r4 bx r4
#endif /* !THUMB_NO_INTERWORKING */ #endif /* !THUMB_NO_INTERWORKING */
/** @endcond */ #endif /* !defined(__DOXYGEN__) */
/** @} */ /** @} */

View File

@ -136,7 +136,7 @@ IVOR4:
ori %r3, %r3, INTC_EOIR@l ori %r3, %r3, INTC_EOIR@l
stw %r3, 0(%r3) /* Writing any value should do. */ stw %r3, 0(%r3) /* Writing any value should do. */
/* Verifies if a reschedulation is required.*/ /* Verifies if a reschedule is required.*/
bl chSchIsRescRequiredExI bl chSchIsRescRequiredExI
cmpli cr0, %r3, 0 cmpli cr0, %r3, 0
beq cr0, .ctxrestore beq cr0, .ctxrestore

View File

@ -91,7 +91,7 @@
*** 1.5.3 *** *** 1.5.3 ***
- FIX: Removed C99-style variables declarations (bug 2964418)(backported - FIX: Removed C99-style variables declarations (bug 2964418)(backported
in 1.4.2). in 1.4.2).
- FIX: Fixed missing reschedulation in chEvtSignal() (bug 2961208)(backported - FIX: Fixed missing reschedule in chEvtSignal() (bug 2961208)(backported
in 1.4.2). in 1.4.2).
- NEW: Added STM8 port and demo, the demo targets the Raisonance REva board - NEW: Added STM8 port and demo, the demo targets the Raisonance REva board
with STM8S208RB piggyback. with STM8S208RB piggyback.
@ -835,14 +835,14 @@
faster if the feature is not required. Threads at the same priority level faster if the feature is not required. Threads at the same priority level
are still supported when the feature is disabled but the scheduling among are still supported when the feature is disabled but the scheduling among
them becomes cooperative. them becomes cooperative.
- OPT: Improved reschedulation time by reordering the sequence of operations, - OPT: Improved reschedule time by reordering the sequence of operations,
now during enqueuing the ready list contains one less element. This change now during enqueuing the ready list contains one less element. This change
also slightly improves the interrupt latency. also slightly improves the interrupt latency.
- OPT: Optimization to the chSemReset(), reversed the order of dequeuing. - OPT: Optimization to the chSemReset(), reversed the order of dequeuing.
- FIX: Fixed a bug in the chThdSetPriority() API. - FIX: Fixed a bug in the chThdSetPriority() API.
- FIX: Modified the structure names into nvic.h in order to not make them - FIX: Modified the structure names into nvic.h in order to not make them
collide with external libraries. collide with external libraries.
- Added a benchmark to the test suit that measures the mass reschedulation - Added a benchmark to the test suit that measures the mass reschedule
performance. performance.
- Added a test_terminate_threads() function to the test framework. - Added a test_terminate_threads() function to the test framework.
- Made the Cortex-M3 port preemption code more readable. - Made the Cortex-M3 port preemption code more readable.

View File

@ -356,7 +356,7 @@ const struct testcase testbmk6 = {
}; };
/** /**
* @page test_benchmarks_007 Mass reschedulation performance * @page test_benchmarks_007 Mass reschedule performance
* *
* <h2>Description</h2> * <h2>Description</h2>
* Five threads are created and atomically reschedulated by resetting the * Five threads are created and atomically reschedulated by resetting the
@ -376,7 +376,7 @@ static msg_t thread3(void *p) {
static char *bmk7_gettest(void) { static char *bmk7_gettest(void) {
return "Benchmark, mass reschedulation, 5 threads"; return "Benchmark, mass reschedule, 5 threads";
} }
static void bmk7_setup(void) { static void bmk7_setup(void) {
@ -409,7 +409,7 @@ static void bmk7_execute(void) {
test_print("--- Score : "); test_print("--- Score : ");
test_printn(n); test_printn(n);
test_print(" reschedulations/S, "); test_print(" reschedules/S, ");
test_printn(n * 6); test_printn(n * 6);
test_println(" ctxswc/S"); test_println(" ctxswc/S");
} }
@ -422,7 +422,7 @@ const struct testcase testbmk7 = {
}; };
/** /**
* @page test_benchmarks_008 I/O Round-Robin voluntary reschedulation. * @page test_benchmarks_008 I/O Round-Robin voluntary reschedule.
* *
* <h2>Description</h2> * <h2>Description</h2>
* Five threads are created at equal priority, each thread just increases a * Five threads are created at equal priority, each thread just increases a
@ -469,7 +469,7 @@ static void bmk8_execute(void) {
test_print("--- Score : "); test_print("--- Score : ");
test_printn(n); test_printn(n);
test_print(" reschedulations/S, "); test_print(" reschedules/S, ");
test_printn(n); test_printn(n);
test_println(" ctxswc/S"); test_println(" ctxswc/S");
} }