NVIDIA Interview Question

implement a semaphore, not very difficult.