News for hackers. Stuff that matters.
Re:A spin lock in C that does not require a machine level ex... by jpollock on Sunday May 04, 2014 @08:23PM (#7696435)
Both the compiler and CPU will reorder operations. Proper locking requires a memory barrier which will prevent both CPU and compiler from doing that. For more information I recommend reading up on double checked locking. DDJ had a good pair of articles the first where they presented the faulty algorithm, the second where they talked about why it was broken.

C/c++ doesn't have many guarantees about operation ordering. http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLo...

There are no comments on this comment yet.