+ // Grab the lock to avoid races with wake_sleeping_thread()
+ lock_grab(&SleepLock[threadID]);
+
+ // If we are master and all slaves have finished do not go to sleep
+ for (i = 0; sp && i < ActiveThreads && !sp->slaves[i]; i++) {}
+ allFinished = (i == ActiveThreads);