LibC: Make pthread_barrier safe

It used to deadlock and it was not safe if more threads than the target
were attempting to wait on it.
This commit is contained in:
2025-08-04 19:08:50 +03:00
parent 57c9f5a8a8
commit 658a001d91
2 changed files with 28 additions and 19 deletions

View File

@@ -28,17 +28,6 @@ typedef struct
unsigned lock_depth;
} pthread_mutex_t;
typedef struct
{
int shared;
} pthread_barrierattr_t;
typedef struct
{
pthread_barrierattr_t attr;
unsigned target;
unsigned waiting;
} pthread_barrier_t;
typedef struct
{
int clock;
@@ -56,6 +45,20 @@ typedef struct
struct _pthread_cond_block* block_list;
} pthread_cond_t;
typedef struct
{
int shared;
} pthread_barrierattr_t;
typedef struct
{
pthread_barrierattr_t attr;
pthread_mutex_t lock;
pthread_cond_t cond;
unsigned target;
unsigned waiting;
unsigned generation;
} pthread_barrier_t;
typedef struct
{
int shared;