Skip to content

Commit

Permalink
Remove racey condition for starting threads (#4693)
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol authored Aug 5, 2024
1 parent ac11d66 commit 6061296
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/ttsafe_semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ tts_semaphore_pingpong(void)
herr_t result;

/* Test set up */
/* NOTE: ping semaphore starts at 1 */
result = H5TS_semaphore_init(&test_info.ping_sem, 1);
result = H5TS_semaphore_init(&test_info.ping_sem, 0);
CHECK_I(result, "H5TS_semaphore_init");
result = H5TS_semaphore_init(&test_info.pong_sem, 0);
CHECK_I(result, "H5TS_semaphore_init");
Expand All @@ -102,6 +101,10 @@ tts_semaphore_pingpong(void)
result = H5TS_thread_create(&pong_thread, pong, &test_info);
CHECK_I(result, "H5TS_thread_create");

/* Release ping thread */
result = H5TS_semaphore_signal(&test_info.ping_sem);
CHECK_I(result, "H5TS_semaphore_signal");

/* Join ping & pong threads */
result = H5TS_thread_join(ping_thread, NULL);
CHECK_I(result, "H5TS_thread_join");
Expand Down

0 comments on commit 6061296

Please sign in to comment.