A simple implementation idea for a barrier using a lock is to have a counter, and have each thread acquire the lock, check if the counter is the same as the number of threads and if not continuously loop checking this case. This can also be improved using a semaphore. I couldn't come up with a way to implement a lock using a barrier, however. If anyone thinks of something, please drop them.
A simple implementation idea for a barrier using a lock is to have a counter, and have each thread acquire the lock, check if the counter is the same as the number of threads and if not continuously loop checking this case. This can also be improved using a semaphore. I couldn't come up with a way to implement a lock using a barrier, however. If anyone thinks of something, please drop them.