add semaphore into the lock