KallistiOS git master
Independent SDK for the Sega Dreamcast
|
KOS barrier API for kernel threads More...
Files | |
file | barrier.h |
Thread barriers. | |
Data Structures | |
union | thd_barrier_t |
Thread barrier type. More... | |
Macros | |
#define | THD_BARRIER_SERIAL_THREAD 0x7fffffff |
Constant returned to one thread from pthread_barrier_wait(). | |
#define | THD_BARRIER_SIZE 64 |
Size of a thread barrier, in bytes. | |
Functions | |
int | thd_barrier_init (thd_barrier_t *__RESTRICT barrier, const void *__RESTRICT attr, unsigned count) |
Initialize a thread barrier. | |
int | thd_barrier_destroy (thd_barrier_t *barrier) |
Destroy a thread barrier. | |
int | thd_barrier_wait (thd_barrier_t *barrier) |
Wait on a thread barrier. | |
KOS barrier API for kernel threads
Barriers are a type of synchronization method which halt execution for group of threads until a certain number of them have reached the barrier.
#define THD_BARRIER_SERIAL_THREAD 0x7fffffff |
Constant returned to one thread from pthread_barrier_wait().
A single (unspecified) thread will be returned this value after successfully waiting on a barrier, with all other threads being returned a 0. This is useful for selecting one thread to perform any cleanup work associated with the barrier (or other serial work that must be performed).
#define THD_BARRIER_SIZE 64 |
Size of a thread barrier, in bytes.
int thd_barrier_destroy | ( | thd_barrier_t * | barrier | ) |
Destroy a thread barrier.
This function destroys a thread barrier, releasing any resources associated with the barrier. Subsequent use of the barrier is results in undefined behavior unless it is later re-initialized with thd_barrier_init().
barrier | The barrier to destroy. |
int thd_barrier_init | ( | thd_barrier_t *__RESTRICT | barrier, |
const void *__RESTRICT | attr, | ||
unsigned | count ) |
Initialize a thread barrier.
This function initializes a thread barrier for use among the specified number of threads.
barrier | The barrier to initialize. |
attr | Reserved for POSIX compatibility. Always pass NULL. |
count | The number of threads the barrier will expect. |
int thd_barrier_wait | ( | thd_barrier_t * | barrier | ) |
Wait on a thread barrier.
This function synchronizes the participating threads at the barrier specified. The calling thread will block until the required number of threads (specified by the barrier's count) have called this function to wait on the barrier.
barrier | The barrier to wait on. |