Question: Implement barrier_wait with condvars. Threads call the mybarrier_wait function to wait at a barrier until 'n' threads have called mybarrier_wait. Use the prototypes below.
Implement barrier_wait with condvars. Threads call the mybarrier_wait function to wait at a barrier until 'n' threads have called mybarrier_wait. Use the prototypes below. We have provided the initialization. In your implementation, be sure to reset the count to 0 when the barrier falls. Comments in your code are appreciated to help us understand your reasoning! typedef struct { pthread_mutex_t count_lock; pthread_cond_t barrier_falls; int count; } mybarrier_t void mybarrier_init(mybarrier_t *b) { b->count = 0; pthread_mutex init(&(b->count_lock), NULL); pthread_cond init(&(b->barrier_falls), NULL); } void mybarrier_wait(mybarrier_t *b, int n) { FILL IN HERE }
Step by Step Solution
3.43 Rating (162 Votes )
There are 3 Steps involved in it
The code provided lacks the implementation of the mybarrierwait function which is essential for crea... View full answer
Get step-by-step solutions from verified subject matter experts
