GridGain interview question

Implement a reentrant lock based on a CAS primitive.