in reply to baton passing threads and cond_signal

cond_signal wakes an arbitrary thread that's waiting on the argument, not the thread specified by the argument.

If you wanted to use cond_signal, you'd have to replace

cond_wait ($baton) until $baton == $id;

with

for (;;) { cond_wait ($baton); last if $baton == $id; # This isn't the right sprinter, so try another. cond_signal ($baton); }

I don't know which approach is better.