tests/mutex_unlock_and_sleep: replace modulo to speed up tests on wsn430
Doing a 32 bit modulo is really slow on wsn430, even when changing to a power of two modulo. Replace modulo by a double counter.
This commit is contained in:
parent
736c757b80
commit
2dfb5847f3
@ -27,6 +27,8 @@ static volatile int indicator;
|
||||
static kernel_pid_t main_pid;
|
||||
static char stack[THREAD_STACKSIZE_DEFAULT];
|
||||
|
||||
static const unsigned KITERATIONS = 100;
|
||||
|
||||
static void *second_thread(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
@ -42,6 +44,7 @@ static void *second_thread(void *arg)
|
||||
int main(void)
|
||||
{
|
||||
uint32_t count = 0;
|
||||
uint32_t kcount = 0;
|
||||
|
||||
indicator = 0;
|
||||
main_pid = thread_getpid();
|
||||
@ -64,8 +67,10 @@ int main(void)
|
||||
printf("[ERROR] threads did not sleep properly (%d).\n", indicator);
|
||||
return 1;
|
||||
}
|
||||
if ((count % 100000) == 0) {
|
||||
printf("[ALIVE] alternated %"PRIu32"k times.\n", (count / 1000));
|
||||
if (count == (KITERATIONS * 1000)) {
|
||||
count = 0;
|
||||
kcount += KITERATIONS;
|
||||
printf("[ALIVE] alternated %"PRIu32"k times.\n", kcount);
|
||||
}
|
||||
mutex_unlock_and_sleep(&mutex);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user