'volatile'에 해당되는 글 1건

  1. C의 volatile 키워드 2010.03.23
The C++ standard has little to say about volatile.  It was originally intended for the very specific application of writing device drivers that communicate with hardware via memory-mapped I/O. 

  • To make that work, compilers must follow these rules:
  • A read or write to a volatile variable must not be eliminated by the compiler. Reads and writes to volatile variables must not be reordered by the compiler, relative to one-another.
(출처 - http://blogs.msdn.com/ericeil/archive/2007/10/26/fun-programming-problem-a-simple-lock-free-algorithm.aspx)

그렇다면 결국 volatile 키워드가 하는 일은 간단히 말해, 최적화를 하지 않고, 접근해야 할 메모리에 순서대로 제대로 접근하게 하는 일일 것이다.



,