Skip to content

Commit

Permalink
tests/isr_yield_higher: adapt TEST_TIME to start-up time
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Oct 22, 2019
1 parent 04712db commit d16cf08
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/isr_yield_higher/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
#define TEST_TIME (200000U)

static char t2_stack[THREAD_STACKSIZE_MAIN];
static uint32_t start_time;

static void *second_thread(void *arg)
{
(void) arg;
if (xtimer_now_usec() < TEST_TIME) {
uint32_t *start_time = (uint32_t *)arg;

if (xtimer_now_usec() < (TEST_TIME + *start_time)) {
puts("TEST FAILED");
}
else {
Expand All @@ -49,19 +51,21 @@ static void _cb(void *arg)

int main(void)
{
(void) thread_create(
t2_stack, sizeof(t2_stack),
THREAD_PRIORITY_MAIN,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread, NULL, "nr2");

puts("first thread started");

start_time = xtimer_now_usec();

xtimer_t timer;
timer.callback = _cb;
xtimer_set(&timer, TEST_TIME/2);
xtimer_set(&timer, TEST_TIME / 2);

(void)thread_create(
t2_stack, sizeof(t2_stack),
THREAD_PRIORITY_MAIN,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
second_thread, &start_time, "nr2");

while(xtimer_now_usec() < TEST_TIME) {}
while (xtimer_now_usec() < (TEST_TIME + start_time)) {}

puts("first thread done");

Expand Down

0 comments on commit d16cf08

Please sign in to comment.