From d15e4281eddf974766f31cbb8f328b044a60a171 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 31 Aug 2024 08:41:27 -0500 Subject: [PATCH] Switch back to regular (non-atomic) counter variables Signed-off-by: Quincey Koziol --- test/ttsafe_semaphore.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/ttsafe_semaphore.c b/test/ttsafe_semaphore.c index b8a3dece723..bec4c3bd4eb 100644 --- a/test/ttsafe_semaphore.c +++ b/test/ttsafe_semaphore.c @@ -27,8 +27,8 @@ typedef struct { H5TS_semaphore_t ping_sem, pong_sem; - H5TS_atomic_uint_t ping_counter; - H5TS_atomic_uint_t pong_counter; + unsigned ping_counter; + unsigned pong_counter; } pingpong_t; typedef struct { @@ -48,11 +48,11 @@ ping(void *_test_info) result = H5TS_semaphore_wait(&test_info->ping_sem); CHECK_I(result, "H5TS_semaphore_wait"); - H5TS_atomic_fetch_add_uint(&test_info->ping_counter, (unsigned)1); + test_info->ping_counter++; result = H5TS_semaphore_signal(&test_info->pong_sem); CHECK_I(result, "H5TS_semaphore_signal"); - } while (H5TS_atomic_load_uint(&test_info->ping_counter) < NUM_PINGPONG); + } while (test_info->ping_counter < NUM_PINGPONG); return ret_value; } @@ -68,11 +68,11 @@ pong(void *_test_info) result = H5TS_semaphore_wait(&test_info->pong_sem); CHECK_I(result, "H5TS_semaphore_wait"); - H5TS_atomic_fetch_add_uint(&test_info->pong_counter, (unsigned)1); + test_info->pong_counter++; result = H5TS_semaphore_signal(&test_info->ping_sem); CHECK_I(result, "H5TS_semaphore_signal"); - } while (H5TS_atomic_load_uint(&test_info->pong_counter) < NUM_PINGPONG); + } while (test_info->pong_counter < NUM_PINGPONG); return ret_value; } @@ -94,8 +94,8 @@ tts_semaphore_pingpong(void) CHECK_I(result, "H5TS_semaphore_init"); result = H5TS_semaphore_init(&test_info.pong_sem, 0); CHECK_I(result, "H5TS_semaphore_init"); - H5TS_atomic_init_uint(&test_info.ping_counter, (unsigned)0); - H5TS_atomic_init_uint(&test_info.pong_counter, (unsigned)0); + test_info.ping_counter = 0; + test_info.pong_counter = 0; /* Start ping & pong threads */ result = H5TS_thread_create(&ping_thread, ping, &test_info); @@ -113,17 +113,14 @@ tts_semaphore_pingpong(void) result = H5TS_thread_join(pong_thread, NULL); CHECK_I(result, "H5TS_thread_join"); - VERIFY(H5TS_atomic_load_uint(&test_info.ping_counter), NUM_PINGPONG, "ping counter"); - VERIFY(H5TS_atomic_load_uint(&test_info.pong_counter), NUM_PINGPONG, "pong counter"); + VERIFY(test_info.ping_counter, NUM_PINGPONG, "ping counter"); + VERIFY(test_info.pong_counter, NUM_PINGPONG, "pong counter"); - /* Destroy semaphores, etc. */ + /* Destroy semaphores */ result = H5TS_semaphore_destroy(&test_info.ping_sem); CHECK_I(result, "H5TS_semaphore_destroy"); result = H5TS_semaphore_destroy(&test_info.pong_sem); CHECK_I(result, "H5TS_semaphore_destroy"); - - H5TS_atomic_destroy_uint(&test_info.ping_counter); - H5TS_atomic_destroy_uint(&test_info.pong_counter); } /* end tts_semaphore_pingpong() */ static H5TS_THREAD_RETURN_TYPE