updated semaphore without busy waiting and spinlock