Got it sort of working with semaphores, except there is a race condition
half the time, and the results are slightly out (too accurate?)