EarnIn Interview Question

How would you implement a mutex from scratch?