Skip to content

Commit

Permalink
tests/thread_float: improve console output
Browse files Browse the repository at this point in the history
Give the three threads the names "t1", "t2", and "t3" and print them
on console, instead of the process ID. This makes interpretation of
the output easier, as the process IDs depend e.g. on whether a given
platforms requires an idle thread or not.
  • Loading branch information
maribu committed Sep 28, 2021
1 parent 7313a1c commit 991915a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/thread_float/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ static void timer_cb(void *arg)

static void *thread1(void *arg)
{
(void) arg;

float f, init;

printf("THREAD %" PRIkernel_pid " start\n", thread_getpid());
printf("THREAD %s start\n", (const char *)arg);

init = 1.0 * thread_getpid();
f = init;
Expand All @@ -60,7 +58,7 @@ static void *thread1(void *arg)
f = f + 1.0 / f;
}
mutex_lock(&lock);
printf("T(%" PRIkernel_pid "): %f\n", thread_getpid(), (double)f);
printf("%s: %f\n", (const char *)arg, (double)f);
mutex_unlock(&lock);
init += 1.0;
f = init;
Expand All @@ -70,11 +68,9 @@ static void *thread1(void *arg)

static void *thread2(void *arg)
{
(void) arg;

float f, init;

printf("THREAD %" PRIkernel_pid " start\n", thread_getpid());
printf("THREAD %s start\n", (const char *)arg);

init = 1.0 * thread_getpid();
f = init;
Expand All @@ -91,15 +87,18 @@ static void *thread2(void *arg)

int main(void)
{
const char *t1_name = "t1";
const char *t2_name = "t2";
const char *t3_name = "t3";
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN + 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread1, NULL, "nr1");
thread1, (void *)t1_name, t1_name);
p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN + 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread2, NULL, "nr2");
thread2, (void *)t2_name, t2_name);
p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN + 1,
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
thread1, NULL, "nr3");
thread1, (void *)t3_name, t3_name);
puts("THREADS CREATED\n");

timer.callback = timer_cb;
Expand Down

0 comments on commit 991915a

Please # to comment.