Question: There is another synchronization method other than the ones taught in class called a barrier. Barriers make sure that all threads stop at a certain

There is another synchronization method other than the ones taught in class called a barrier. Barriers make sure that all threads stop at a certain point before continuing. An example would be a parallel read/sort function. Several threads would read some data in parallel and stop at a barrier before moving on to do the actual sort. extern static int NUM_THREADS; // assume the number of threads does not change // you may add additional members to this struct, // but NO NEW synchronization primatives typedef struct { spinlock_t lock; } barrier_t; Part A (5 points): Implement the initialization function below. Remember to initialize any members you added to the barrier-t struct. void barrier_init (barrier_t *b) { Part B (10 points): Implement a barrier_wait function below. void barrier_wait (barrier_t *b) There is another synchronization method other than the ones taught in class called a barrier. Barriers make sure that all threads stop at a certain point before continuing. An example would be a parallel read/sort function. Several threads would read some data in parallel and stop at a barrier before moving on to do the actual sort. extern static int NUM_THREADS; // assume the number of threads does not change // you may add additional members to this struct, // but NO NEW synchronization primatives typedef struct { spinlock_t lock; } barrier_t; Part A (5 points): Implement the initialization function below. Remember to initialize any members you added to the barrier-t struct. void barrier_init (barrier_t *b) { Part B (10 points): Implement a barrier_wait function below. void barrier_wait (barrier_t *b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
