Lock/Barriers Consider a cache-coherent multiprocessor. Ass…
Lock/Barriers Consider a cache-coherent multiprocessor. Assume the multiprocessor offers an atomic decrement operation on a shared variable. You decide to provide a barrier synchronization primitive in your OS that is based on the following count-based algorithm: int count = N; // initialized to the number of participating threads barrier()0. {1. decrement(count);2. if (count == 0)3. count = N; // last processor to arrive 4. else5. while (count > 0); // wait for last process 6. while (count!= N);//to not leave barrier before count reset7. } Identify any two race conditions that will lead to the algorithm not working as written above.