tests/pthread_condition_variable: adapt for slow boards
Reduce the number of required iterations on boards. This will allow running it on 'arduino-mega2560'.
This commit is contained in:
parent
624957252e
commit
5c405b56f8
@ -26,7 +26,6 @@ static mutex_t mutex = MUTEX_INIT;
|
|||||||
static pthread_cond_t cv;
|
static pthread_cond_t cv;
|
||||||
static volatile int is_finished;
|
static volatile int is_finished;
|
||||||
static volatile long count;
|
static volatile long count;
|
||||||
static volatile long expected_value;
|
|
||||||
static char stack[THREAD_STACKSIZE_MAIN];
|
static char stack[THREAD_STACKSIZE_MAIN];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,12 +49,17 @@ static void *second_thread(void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BOARD_NATIVE
|
||||||
|
#define ITERATION_STEPS 100000
|
||||||
|
#else
|
||||||
|
#define ITERATION_STEPS 10000
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
puts("START");
|
puts("START");
|
||||||
count = 0;
|
count = 0;
|
||||||
is_finished = 0;
|
is_finished = 0;
|
||||||
expected_value = 1000ul * 1000ul;
|
|
||||||
pthread_cond_init(&cv, NULL);
|
pthread_cond_init(&cv, NULL);
|
||||||
|
|
||||||
kernel_pid_t pid = thread_create(stack,sizeof(stack), THREAD_PRIORITY_MAIN - 1,
|
kernel_pid_t pid = thread_create(stack,sizeof(stack), THREAD_PRIORITY_MAIN - 1,
|
||||||
@ -67,11 +71,11 @@ int main(void)
|
|||||||
thread_wakeup(pid);
|
thread_wakeup(pid);
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if ((count % 100000) == 0) {
|
if ((count % ITERATION_STEPS) == 0) {
|
||||||
printf("Still alive alternated [count: %ldk] times.\n", count / 1000);
|
printf("Still alive alternated [count: %ldk] times.\n", count / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == expected_value) {
|
if (count == (10ul * ITERATION_STEPS)) {
|
||||||
puts("condition fulfilled.");
|
puts("condition fulfilled.");
|
||||||
is_finished = 1;
|
is_finished = 1;
|
||||||
mutex_unlock(&mutex);
|
mutex_unlock(&mutex);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user