diff options
Diffstat (limited to 'test/rt/testbmk.c')
-rw-r--r-- | test/rt/testbmk.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/test/rt/testbmk.c b/test/rt/testbmk.c index 639ba2b7b..1bffbc4df 100644 --- a/test/rt/testbmk.c +++ b/test/rt/testbmk.c @@ -344,7 +344,8 @@ ROMCONST struct testcase testbmk6 = { static THD_FUNCTION(thread3, p) {
- while (!*(bool *)p)
+ (void)p;
+ while (!chThdShouldTerminateX())
chSemWait(&sem1);
}
@@ -355,13 +356,12 @@ static void bmk7_setup(void) { static void bmk7_execute(void) {
uint32_t n;
- bool terminate = false;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, &terminate);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, &terminate);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, &terminate);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, &terminate);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, &terminate);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, NULL);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, NULL);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, NULL);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, NULL);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, NULL);
n = 0;
test_wait_tick();
@@ -373,7 +373,7 @@ static void bmk7_execute(void) { _sim_check_for_interrupts();
#endif
} while (!test_timer_done);
- terminate = true;
+ test_terminate_threads();
chSemReset(&sem1, 0);
test_wait_threads();
@@ -401,44 +401,39 @@ ROMCONST struct testcase testbmk7 = { * The performance is calculated by measuring the number of iterations after
* a second of continuous operations.
*/
-typedef struct {
- bool terminate;
- uint32_t n;
-} params_t;
static THD_FUNCTION(thread8, p) {
- params_t *pp = (params_t *)p;
do {
chThdYield();
chThdYield();
chThdYield();
chThdYield();
- pp->n += 4;
+ (*(uint32_t *)p) += 4;
#if defined(SIMULATOR)
_sim_check_for_interrupts();
#endif
- } while (!pp->terminate);
+ } while(!chThdShouldTerminateX());
}
static void bmk8_execute(void) {
- params_t params = {false, 0};
+ uint32_t n;
- params.n = 0;
+ n = 0;
test_wait_tick();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)¶ms);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)¶ms);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)¶ms);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)¶ms);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)¶ms);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
chThdSleepSeconds(1);
- params.terminate = true;
+ test_terminate_threads();
test_wait_threads();
test_print("--- Score : ");
- test_printn(params.n);
+ test_printn(n);
test_println(" ctxswc/S");
}
|