Added pthread semaphore.