NVIDIA interview question

implement a semaphore, not very difficult.