updated semaphore with busy waiting and spinlock