0

I am trying to implement the Reusable Barrier algorithm from "Little Book of Semaphores", but without using a counter. I thought about an implementation where I may use 4 barriers, but I cannot find a way of knowing when all threads have passed first two barriers for example. Also, another implementation that I thought about is with some boolean variables:

def threadA():
  isOpenA = True
  barrierA.wait()
  isOpenA = False
  barrierA.signal()
  isOpenA = True
  while isOpenA == True:
    #hold threads here until each one arrives  
  #barrierB wait
  #signal barrierB

Is there a possible way to implement the Reusable Barrier without using a counter?

Razvan
  • 143
  • 8
  • Does [this](https://stackoverflow.com/questions/5049294/reusable-barrier-algorithm) or [this](https://stackoverflow.com/questions/10168874) answer your question? – Jérôme Richard May 26 '21 at 19:48
  • @JérômeRichard In my implementation I am not allowed to use a counter variable for counting how many threads entered the first barrier respectively exited the second one. So, no, neither one of the links provides an answer to my question. – Razvan May 26 '21 at 20:30

0 Answers0