diff --git a/test/rt/nanos6/spawn-task-external-bad.c b/test/rt/nanos6/spawn-task-external-bad.c index f9d6691..5e0dbaf 100644 --- a/test/rt/nanos6/spawn-task-external-bad.c +++ b/test/rt/nanos6/spawn-task-external-bad.c @@ -10,8 +10,9 @@ #include #include -#include #include +#include +#include #include "common.h" @@ -45,8 +46,7 @@ polling_func(void *arg) static void * spawn(void *arg) { - double ms = *((double *) arg); - nanos6_spawn_function(polling_func, &ms, NULL, NULL, "polling_task"); + nanos6_spawn_function(polling_func, arg, NULL, NULL, "polling_task"); return NULL; } @@ -54,7 +54,11 @@ int main(void) { pthread_t th; - double T = 100.0; + double *T = malloc(sizeof(double)); + if (T == NULL) + die("malloc failed:"); + + *T = 100.0; if (pthread_create(&th, NULL, spawn, &T) != 0) die("pthread_create failed:"); @@ -63,7 +67,7 @@ main(void) die("pthread_join failed:"); #pragma oss task label("dummy_task") - dummy_work(T); + dummy_work(*T); #pragma oss taskwait diff --git a/test/rt/nanos6/spawn-task-external.c b/test/rt/nanos6/spawn-task-external.c index ceb49cc..470c82c 100644 --- a/test/rt/nanos6/spawn-task-external.c +++ b/test/rt/nanos6/spawn-task-external.c @@ -10,8 +10,9 @@ #include #include -#include #include +#include +#include #include "common.h" #include "compat.h" @@ -81,8 +82,7 @@ spawn(void *arg) /* Inform ovni of this external thread */ instr_thread_start(-1, -1, 0); - double ms = *((double *) arg); - nanos6_spawn_function(polling_func, &ms, NULL, NULL, "polling_task"); + nanos6_spawn_function(polling_func, arg, NULL, NULL, "polling_task"); /* Then inform that the thread finishes */ instr_thread_end(); @@ -94,16 +94,20 @@ int main(void) { pthread_t th; - double T = 100.0; + double *T = malloc(sizeof(double)); + if (T == NULL) + die("malloc failed:"); - if (pthread_create(&th, NULL, spawn, &T) != 0) + *T = 100.0; + + if (pthread_create(&th, NULL, spawn, T) != 0) die("pthread_create failed:"); if (pthread_join(th, NULL) != 0) die("pthread_join failed:"); #pragma oss task label("dummy_task") - dummy_work(T); + dummy_work(*T); #pragma oss taskwait diff --git a/test/rt/nanos6/spawn-task.c b/test/rt/nanos6/spawn-task.c index bff54f0..61436bd 100644 --- a/test/rt/nanos6/spawn-task.c +++ b/test/rt/nanos6/spawn-task.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "common.h" @@ -41,12 +42,16 @@ polling_func(void *arg) int main(void) { - double T = 100.0; + double *T = malloc(sizeof(double)); + if (T == NULL) + die("malloc failed:"); - nanos6_spawn_function(polling_func, &T, NULL, NULL, "polling_task"); + *T = 100.0; + + nanos6_spawn_function(polling_func, T, NULL, NULL, "polling_task"); #pragma oss task label("dummy_task") - dummy_work(T); + dummy_work(*T); #pragma oss taskwait