Hacker News new | ask | show | jobs
by ww520 1592 days ago
You are right. XCHG can do the job to acquire the lock. At least on x86, XCHG does lock the cache line on the address of the variable, so it should be ok.