diff mbox

validation: shmem: sync threads with barrier

Message ID 1453486140-5511-1-git-send-email-ivan.khoronzhuk@linaro.org
State Superseded
Headers show

Commit Message

Ivan Khoronzhuk Jan. 22, 2016, 6:09 p.m. UTC
It's not convenient to see reused a thread id for threads that are
finished to fast.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 test/validation/shmem/shmem.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Ivan Khoronzhuk Jan. 22, 2016, 6:14 p.m. UTC | #1
see v2

On 22.01.16 20:09, Ivan Khoronzhuk wrote:
> It's not convenient to see reused a thread id for threads that are
> finished to fast.
>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> ---
>   test/validation/shmem/shmem.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c
> index 5524b5c..bb7b424 100644
> --- a/test/validation/shmem/shmem.c
> +++ b/test/validation/shmem/shmem.c
> @@ -13,6 +13,8 @@
>   #define TEST_SHARE_FOO (0xf0f0f0f0)
>   #define TEST_SHARE_BAR (0xf0f0f0f)
>
> +static odp_barrier_t test_barrier;
> +
>   static void *run_shm_thread(void *arg)
>   {
>   	odp_shm_info_t  info;
> @@ -20,6 +22,7 @@ static void *run_shm_thread(void *arg)
>   	test_shared_data_t *test_shared_data;
>   	int thr;
>
> +	odp_barrier_wait(&test_barrier);
>   	thr = odp_thread_id();
>   	printf("Thread %i starts\n", thr);
>
> @@ -72,6 +75,7 @@ void shmem_test_odp_shm_sunnyday(void)
>   	if (thrdarg.numthrds > MAX_WORKERS)
>   		thrdarg.numthrds = MAX_WORKERS;
>
> +	odp_barrier_init(test_barrier, thrdarg.numthrds);
>   	odp_cunit_thread_create(run_shm_thread, &thrdarg);
>   	odp_cunit_thread_exit(&thrdarg);
>   }
>
diff mbox

Patch

diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c
index 5524b5c..bb7b424 100644
--- a/test/validation/shmem/shmem.c
+++ b/test/validation/shmem/shmem.c
@@ -13,6 +13,8 @@ 
 #define TEST_SHARE_FOO (0xf0f0f0f0)
 #define TEST_SHARE_BAR (0xf0f0f0f)
 
+static odp_barrier_t test_barrier;
+
 static void *run_shm_thread(void *arg)
 {
 	odp_shm_info_t  info;
@@ -20,6 +22,7 @@  static void *run_shm_thread(void *arg)
 	test_shared_data_t *test_shared_data;
 	int thr;
 
+	odp_barrier_wait(&test_barrier);
 	thr = odp_thread_id();
 	printf("Thread %i starts\n", thr);
 
@@ -72,6 +75,7 @@  void shmem_test_odp_shm_sunnyday(void)
 	if (thrdarg.numthrds > MAX_WORKERS)
 		thrdarg.numthrds = MAX_WORKERS;
 
+	odp_barrier_init(test_barrier, thrdarg.numthrds);
 	odp_cunit_thread_create(run_shm_thread, &thrdarg);
 	odp_cunit_thread_exit(&thrdarg);
 }