add a semaphore to pb sort