Added new benchmarks about semaphores and mutexes to the test suite.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@804 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
c6a781e7ae
commit
eb75c053eb
|
@ -33,7 +33,8 @@
|
|||
* stack. This is an important feature in a multithreaded environment,
|
||||
* without a dedicated interrupt stack each thread has to reserve
|
||||
* enough space, for interrupts servicing, within its own stack. This space,
|
||||
* multiplied by the total threads number, can be a significant RAM waste.
|
||||
* multiplied by the total threads number, can amount to a significant RAM
|
||||
* overhead.
|
||||
* - <b>Thread Stack</b>, each thread has a dedicated stack for its own
|
||||
* execution and context switch.
|
||||
* - <b>Other Stacks</b>, some architectures (ARM) can have other stacks but
|
||||
|
@ -46,7 +47,7 @@
|
|||
* Assign too much space to a stack wastes RAM, assign too little space
|
||||
* leads to crashes or, worst scenario, hard to track instability.
|
||||
*
|
||||
* <h2>Assign the correct size</h2>
|
||||
* <h2>Assigning the correct size</h2>
|
||||
* You may try to examine the asm listings in order to calculate the exact
|
||||
* stack requirements but this requires much time, experience and patience.<br>
|
||||
* An alternative way is to use an interactive method. Follow this procedure
|
||||
|
@ -78,7 +79,7 @@
|
|||
* .
|
||||
* <h2>Final Notes</h2>
|
||||
* Some useful info:
|
||||
* - Stack overflows are the most common source of problems during development,
|
||||
* - Stack overflows are the most common problems source during development,
|
||||
* when in trouble with crashes or anomalous behaviors always first verify
|
||||
* stack sizes.
|
||||
* - The required stack size can, and very often does change when changing
|
||||
|
|
|
@ -102,7 +102,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
|
|||
implemented on all ports.
|
||||
- Improvements to the test suite, added a new level of indirection that allows
|
||||
to make tests depend on the configuration options without have to put #ifs
|
||||
into the test main module.
|
||||
into the test main module. New benchmarks about semaphores and mutexes.
|
||||
|
||||
*** 1.1.0unstable ***
|
||||
- FIX: Modified the default value for the STM32 HSI setup it was 1, it should
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "test.h"
|
||||
|
||||
static Semaphore sem1;
|
||||
static Mutex mtx1;
|
||||
|
||||
static msg_t thread1(void *p) {
|
||||
msg_t msg;
|
||||
|
@ -328,6 +329,90 @@ const struct testcase testbmk8 = {
|
|||
bmk8_execute
|
||||
};
|
||||
|
||||
static char *bmk9_gettest(void) {
|
||||
|
||||
return "Benchmark, semaphores wait/signal";
|
||||
}
|
||||
|
||||
static void bmk9_setup(void) {
|
||||
|
||||
chSemInit(&sem1, 1);
|
||||
}
|
||||
|
||||
static void bmk9_execute(void) {
|
||||
uint32_t n = 0;
|
||||
|
||||
test_wait_tick();
|
||||
test_start_timer(1000);
|
||||
do {
|
||||
chSemWait(&sem1);
|
||||
chSemSignal(&sem1);
|
||||
chSemWait(&sem1);
|
||||
chSemSignal(&sem1);
|
||||
chSemWait(&sem1);
|
||||
chSemSignal(&sem1);
|
||||
chSemWait(&sem1);
|
||||
chSemSignal(&sem1);
|
||||
n++;
|
||||
#if defined(WIN32)
|
||||
ChkIntSources();
|
||||
#endif
|
||||
} while (!test_timer_done);
|
||||
test_print("--- Score : ");
|
||||
test_printn(n * 4);
|
||||
test_println(" wait+signal/S");
|
||||
}
|
||||
|
||||
const struct testcase testbmk9 = {
|
||||
bmk9_gettest,
|
||||
bmk9_setup,
|
||||
NULL,
|
||||
bmk9_execute
|
||||
};
|
||||
|
||||
#if CH_USE_MUTEXES
|
||||
static char *bmk10_gettest(void) {
|
||||
|
||||
return "Benchmark, mutexes lock/unlock";
|
||||
}
|
||||
|
||||
static void bmk10_setup(void) {
|
||||
|
||||
chMtxInit(&mtx1);
|
||||
}
|
||||
|
||||
static void bmk10_execute(void) {
|
||||
uint32_t n = 0;
|
||||
|
||||
test_wait_tick();
|
||||
test_start_timer(1000);
|
||||
do {
|
||||
chMtxLock(&mtx1);
|
||||
chMtxUnlock();
|
||||
chMtxLock(&mtx1);
|
||||
chMtxUnlock();
|
||||
chMtxLock(&mtx1);
|
||||
chMtxUnlock();
|
||||
chMtxLock(&mtx1);
|
||||
chMtxUnlock();
|
||||
n++;
|
||||
#if defined(WIN32)
|
||||
ChkIntSources();
|
||||
#endif
|
||||
} while (!test_timer_done);
|
||||
test_print("--- Score : ");
|
||||
test_printn(n * 4);
|
||||
test_println(" lock+unlock/S");
|
||||
}
|
||||
|
||||
const struct testcase testbmk10 = {
|
||||
bmk10_gettest,
|
||||
bmk10_setup,
|
||||
NULL,
|
||||
bmk10_execute
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Test sequence for benchmarks pattern.
|
||||
*/
|
||||
|
@ -341,6 +426,10 @@ const struct testcase *patternbmk[] = {
|
|||
&testbmk6,
|
||||
&testbmk7,
|
||||
&testbmk8,
|
||||
&testbmk9,
|
||||
#if CH_USE_MUTEXES
|
||||
&testbmk10,
|
||||
#endif
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
|
3
todo.txt
3
todo.txt
|
@ -21,8 +21,9 @@ After 1.0.0:
|
|||
* Idle loop hook macro.
|
||||
* Switch the configuration options to TRUE/FALSE rather than def/undef.
|
||||
* Remove port_puts() from all the ports.
|
||||
- Stack sizes article into the documentation.
|
||||
* Stack sizes article into the documentation.
|
||||
- Find out and document main stack settings in MSP430 and AVR runtimes.
|
||||
- Logo...
|
||||
|
||||
After 1.2.0:
|
||||
X Abstract I/O channels rather than just serial ports.
|
||||
|
|
Loading…
Reference in New Issue