Use pthread condition variables instead of semaphores