Implemented thread barrier

This commit is contained in:
2024-03-23 21:36:44 +05:30
commit af555db110
61 changed files with 7297 additions and 0 deletions

32
ThreadBarrier.h Normal file
View File

@@ -0,0 +1,32 @@
#ifndef __TH_BARRIER__
#define __TH_BARRIER__
#include <stdbool.h>
#include <stdint.h>
#include <pthread.h>
typedef struct th_barrier_ {
uint32_t threshold_count;
uint32_t curr_wait_count;
pthread_cond_t cv;
pthread_mutex_t mutex;
bool is_ready_again;
pthread_cond_t busy_cv;
}th_barrier_t;
void
thread_barrier_init(th_barrier_t* barrier,
uint32_t threshold_count);
void
thread_barrier_wait(th_barrier_t* barrier);
void
thread_barrier_destroy(th_barrier_t* barrier);
void
thread_barrier_print(th_barrier_t* th_barrier);
#endif