added semaphore for pipelined sort