2007-08-17

Why volatile is practically useless

In the C/C++ programming language, data can be given the volatile qualifier. Typically, people think this is sufficient to prevent code ordering problems. Well, volatile does not do that.

Linus provided a great explanation of the problem on the lkml today. Definitely worth reading. Also, you should read Linux Kernel Memory Barriers from the kernel documentation.

Update 2007-10-14: Also check out the LWN article The Trouble with Volatile.

posted at 15:47 | path:/computer/programming | permanent link