libroot: Implemented pthread barriers

This is an implementation of pthread barriers pursuant to the relevant specification.

Barriers are essentially a special case of conditional variables,
such that all threads waiting on one are woken up when the number of
waiters reaches a number provided at the initialization of the barrier.
In view of that, this implementation mimics the implementation of pthread_cond,
except it is more specialized and self-contained.

Signed-off-by: Jérôme Duval <[email protected]>
This commit is contained in:
Dmytro Shynkevych
2016-12-30 11:32:04 +01:00
committed by Jérôme Duval
parent efd1e1eee8
commit 0e0f49e799
7 changed files with 238 additions and 4 deletions
+10 -4
View File
@@ -60,6 +60,8 @@ typedef struct __timer_t* timer_t;
typedef struct _pthread_thread *pthread_t;
typedef struct _pthread_attr *pthread_attr_t;
typedef struct _pthread_barrier pthread_barrier_t;
typedef struct _pthread_barrierattr *pthread_barrierattr_t;
typedef struct _pthread_mutex pthread_mutex_t;
typedef struct _pthread_mutexattr *pthread_mutexattr_t;
typedef struct _pthread_cond pthread_cond_t;
@@ -69,10 +71,6 @@ typedef struct _pthread_once pthread_once_t;
typedef struct _pthread_rwlock pthread_rwlock_t;
typedef struct _pthread_rwlockattr *pthread_rwlockattr_t;
typedef struct _pthread_spinlock pthread_spinlock_t;
/*
typedef struct _pthread_barrier *pthread_barrier_t;
typedef struct _pthread_barrierattr *pthread_barrierattr_t;
*/
struct _pthread_mutex {
__haiku_std_uint32 flags;
@@ -82,6 +80,14 @@ struct _pthread_mutex {
__haiku_std_int32 owner_count;
};
struct _pthread_barrier {
__haiku_std_uint32 flags;
__haiku_std_int32 lock;
__haiku_std_int32 mutex;
__haiku_std_int32 waiter_count;
__haiku_std_int32 waiter_max;
};
struct _pthread_cond {
__haiku_std_uint32 flags;
__haiku_std_int32 unused;