It often goes unnoticed in multithreaded programming, too, since mutexes, semaphores and events are all designed to prevent memory reordering around their call sites. Thou shalt not modify the behavior of a single-threaded program.Īs a result of this rule, memory reordering goes largely unnoticed by programmers writing single-threaded code. The cardinal rule of memory reordering, which is universally followed by compiler developers and CPU vendors, could be phrased as follows: Changes to memory ordering are made both by the compiler (at compile time) and by the processor (at run time), all in the name of making your code run faster. Between the time you type in some C/C++ source code and the time it executes on a CPU, the memory interactions of that code may be reordered according to certain rules.
0 Comments
Leave a Reply. |