Implemented the semaphore library