Imagine n threads, each of which executes method foo()followed by method bar(). Suppose we want to make sure that no thread starts bar()until all threads have finished foo(). For this kind of synchronization, we place a barrier between foo()and bar().First barrier implementation: We have a counter protected by a test-and-test-and-set lock. Each thread locks the counter, increments it, releases the lock, and spins, rereading the counter until it reaches n. Second barrier implementation: We have an n-element Boolean array b [0..n−1],all initially false. Thread 0 set sb[0] to true. Every threadi,for0
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here