Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/threading_updates' into locking_…
Browse files Browse the repository at this point in the history
…protocol
  • Loading branch information
qkoziol committed May 16, 2024
2 parents aa7d854 + 1e496a5 commit 5ed23d6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
20 changes: 10 additions & 10 deletions src/H5TSbarrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
/*******************/

/*--------------------------------------------------------------------------
* Function: H5TS__barrier_init
* Function: H5TS_barrier_init
*
* Purpose: Initialize a thread barrier
*
Expand All @@ -68,7 +68,7 @@
*--------------------------------------------------------------------------
*/
herr_t
H5TS__barrier_init(H5TS_barrier_t *barrier, unsigned count)
H5TS_barrier_init(H5TS_barrier_t *barrier, unsigned count)
{
herr_t ret_value = SUCCEED;

Expand All @@ -95,22 +95,22 @@ H5TS__barrier_init(H5TS_barrier_t *barrier, unsigned count)

done:
FUNC_LEAVE_NOAPI_NAMECHECK_ONLY(ret_value)
} /* end H5TS__barrier_init() */
} /* end H5TS_barrier_init() */

/*--------------------------------------------------------------------------
* Function: H5TS__barrier_wait
* Function: H5TS_barrier_wait
*
* Purpose: Wait at a barrier.
*
* Note: Similar to pthread_barrier_wait, a barrier may be re-used
* multiple times without intervening calls to H5TS__barrier_init.
* multiple times without intervening calls to H5TS_barrier_init.
*
* Return: Non-negative on success / Negative on failure
*
*--------------------------------------------------------------------------
*/
herr_t
H5TS__barrier_wait(H5TS_barrier_t *barrier)
H5TS_barrier_wait(H5TS_barrier_t *barrier)
{
#ifdef H5_HAVE_PTHREAD_BARRIER
int ret;
Expand Down Expand Up @@ -156,10 +156,10 @@ H5TS__barrier_wait(H5TS_barrier_t *barrier)
#endif

FUNC_LEAVE_NOAPI_NAMECHECK_ONLY(ret_value)
} /* end H5TS__barrier_wait() */
} /* end H5TS_barrier_wait() */

/*--------------------------------------------------------------------------
* Function: H5TS__barrier_destroy
* Function: H5TS_barrier_destroy
*
* Purpose: Destroy an H5TS_barrier_t. All internal components are
* destroyed, but the instance of H5TS_barrier_t is not freed.
Expand All @@ -169,7 +169,7 @@ H5TS__barrier_wait(H5TS_barrier_t *barrier)
*--------------------------------------------------------------------------
*/
herr_t
H5TS__barrier_destroy(H5TS_barrier_t *barrier)
H5TS_barrier_destroy(H5TS_barrier_t *barrier)
{
herr_t ret_value = SUCCEED;

Expand Down Expand Up @@ -209,6 +209,6 @@ H5TS__barrier_destroy(H5TS_barrier_t *barrier)

done:
FUNC_LEAVE_NOAPI_NAMECHECK_ONLY(ret_value)
} /* end H5TS__barrier_destroy() */
} /* end H5TS_barrier_destroy() */

#endif /* H5_HAVE_THREADS */
6 changes: 3 additions & 3 deletions src/H5TSprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ H5_DLL void H5TS_atomic_destroy_uint(H5TS_atomic_uint_t *obj);
#endif /* H5_HAVE_STDATOMIC_H */

/* Barrier related function declarations */
H5_DLL herr_t H5TS__barrier_init(H5TS_barrier_t *barrier, unsigned count);
H5_DLL herr_t H5TS__barrier_wait(H5TS_barrier_t *barrier);
H5_DLL herr_t H5TS__barrier_destroy(H5TS_barrier_t *barrier);
H5_DLL herr_t H5TS_barrier_init(H5TS_barrier_t *barrier, unsigned count);
H5_DLL herr_t H5TS_barrier_wait(H5TS_barrier_t *barrier);
H5_DLL herr_t H5TS_barrier_destroy(H5TS_barrier_t *barrier);

#endif /* H5_HAVE_THREADS */

Expand Down
14 changes: 7 additions & 7 deletions test/ttsafe_cancel.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ tts_cancel(void)
int ret;

/* Initialize barrier */
ret = H5TS__barrier_init(&barrier, 2);
CHECK_I(ret, "H5TS__barrier_init");
ret = H5TS_barrier_init(&barrier, 2);
CHECK_I(ret, "H5TS_barrier_init");

/*
* Create a hdf5 file using H5F_ACC_TRUNC access, default file
Expand All @@ -70,7 +70,7 @@ tts_cancel(void)
assert(cancel_file >= 0);
ret = pthread_create(&childthread, NULL, tts_cancel_thread, NULL);
assert(ret == 0);
ret = H5TS__barrier_wait(&barrier);
ret = H5TS_barrier_wait(&barrier);
assert(ret == 0);
ret = pthread_cancel(childthread);
assert(ret == 0);
Expand All @@ -88,8 +88,8 @@ tts_cancel(void)
ret = H5Fclose(cancel_file);
assert(ret >= 0);

ret = H5TS__barrier_destroy(&barrier);
CHECK_I(ret, "H5TS__barrier_destroy");
ret = H5TS_barrier_destroy(&barrier);
CHECK_I(ret, "H5TS_barrier_destroy");
} /* end tts_cancel() */

void *
Expand Down Expand Up @@ -166,8 +166,8 @@ tts_cancel_callback(void *elem, hid_t H5_ATTR_UNUSED type_id, unsigned H5_ATTR_U
int value = *(int *)elem;
herr_t status;

status = H5TS__barrier_wait(&barrier);
CHECK_I(status, "H5TS__barrier_wait");
status = H5TS_barrier_wait(&barrier);
CHECK_I(status, "H5TS_barrier_wait");

HDsleep(3);

Expand Down
24 changes: 12 additions & 12 deletions test/ttsafe_develop.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ tts_develop_api_thr_1(void *_udata)
CHECK_I(result, "H5TSmutex_acquire");
VERIFY(acquired, true, "H5TSmutex_acquire");

result = H5TS__barrier_wait(udata->barrier);
CHECK_I(result, "H5TS__barrier_wait");
result = H5TS_barrier_wait(udata->barrier);
CHECK_I(result, "H5TS_barrier_wait");

/* Thread #2 will attempt (unsuccessfully) to acquire the API lock */

result = H5TS__barrier_wait(udata->barrier);
CHECK_I(result, "H5TS__barrier_wait");
result = H5TS_barrier_wait(udata->barrier);
CHECK_I(result, "H5TS_barrier_wait");

/* Release the API lock */
result = H5TSmutex_release(&lock_count);
Expand All @@ -73,16 +73,16 @@ tts_develop_api_thr_2(void *_udata)

/* Thread #1 will acquire the API lock */

result = H5TS__barrier_wait(udata->barrier);
CHECK_I(result, "H5TS__barrier_wait");
result = H5TS_barrier_wait(udata->barrier);
CHECK_I(result, "H5TS_barrier_wait");

/* Attempt to acquire the API lock - should not acquire it */
result = H5TSmutex_acquire(1, &acquired);
CHECK_I(result, "H5TSmutex_acquire");
VERIFY(acquired, false, "H5TSmutex_acquire");

result = H5TS__barrier_wait(udata->barrier);
CHECK_I(result, "H5TS__barrier_wait");
result = H5TS_barrier_wait(udata->barrier);
CHECK_I(result, "H5TS_barrier_wait");

/* Thread #1 will release the API lock */

Expand Down Expand Up @@ -122,8 +122,8 @@ tts_develop_api(void)
/* Check H5TSmutex_acquire & H5TSmutex_release in thread callbacks */

/* Create the thread barrier for the two threads */
result = H5TS__barrier_init(&barrier, 2);
CHECK_I(result, "H5TS__barrier_init");
result = H5TS_barrier_init(&barrier, 2);
CHECK_I(result, "H5TS_barrier_init");

/* Create the threads */
udata.barrier = &barrier;
Expand All @@ -138,8 +138,8 @@ tts_develop_api(void)
result = H5TS_thread_join(thread_2, NULL);
CHECK_I(result, "H5TS_thread_join");

result = H5TS__barrier_destroy(&barrier);
CHECK_I(result, "H5TS__barrier_destroy");
result = H5TS_barrier_destroy(&barrier);
CHECK_I(result, "H5TS_barrier_destroy");

/* Test multiple / recursive acquisition of the API lock */

Expand Down
12 changes: 6 additions & 6 deletions test/ttsafe_thread_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ thread_main(void H5_ATTR_UNUSED *arg)
used[tid - 2] = true;
H5TS_mutex_unlock(&used_lock);

H5TS__barrier_wait(&barrier);
H5TS_barrier_wait(&barrier);

/* Verify that the thread ID hasn't changed */
ntid = H5TS_thread_id();
Expand All @@ -80,7 +80,7 @@ thread_main(void H5_ATTR_UNUSED *arg)
return (H5TS_thread_ret_t)0;

pre_barrier_error:
H5TS__barrier_wait(&barrier);
H5TS_barrier_wait(&barrier);

return (H5TS_thread_ret_t)0;
}
Expand All @@ -101,8 +101,8 @@ tts_thread_id(void)

result = H5TS_mutex_init(&used_lock, H5TS_MUTEX_TYPE_PLAIN);
CHECK_I(result, "H5TS_mutex_lock");
result = H5TS__barrier_init(&barrier, NTHREADS);
CHECK_I(result, "H5TS__barrier_init");
result = H5TS_barrier_init(&barrier, NTHREADS);
CHECK_I(result, "H5TS_barrier_init");

/* Get the thread ID for the main thread, so that the child threads
* always start from a thread ID of 2.
Expand All @@ -129,8 +129,8 @@ tts_thread_id(void)
TestErrPrintf("thread ID %d did not run.", i + 1);
}
}
result = H5TS__barrier_destroy(&barrier);
CHECK_I(result, "H5TS__barrier_destroy");
result = H5TS_barrier_destroy(&barrier);
CHECK_I(result, "H5TS_barrier_destroy");

} /* end tts_thread_id() */

Expand Down

0 comments on commit 5ed23d6

Please sign in to comment.