NVIDIA interview question

Implement an atomic compare and swap.