标签

,

After reading two linuxjournal posts,I have learnt the reason for microprocessors to reorder the instruction and how to deal with them.
1.http://www.linuxjournal.com/article/8211
2.http://www.linuxjournal.com/article/8212
(Notes:Also the resource company with the posts are important)

I list some key points here:
1.memory ordering becomes a issue only on SMP systems,except for the optimizing used by compilers on UniProcessor.
2.There are 3 order on one system:
2.1 Program order: the order in which the memory operations are specified in the code running on a given CPU.
2.2 Execution order: the order in which the individual memory-reference instructions are executed on a given CPU. The execution order can differ from program order due to both compiler and CPU-implementation optimizations.
2.3 Perceived order: the order in which a given CPU perceives its and other CPUs’ memory operations. The perceived order can differ from the execution order due to caching, interconnect and memory-system optimizations. Different CPUs might well perceive the same memory operations as occurring in different orders.
3.The Linux kernel is most effected by Alpha cpu which offers weakest memory-ordering model.To understand smp_mb,smp_rmb,smp_wmb and even smp_read_barrier_depends(),one should understand that there is a kind of CPU named Alpha once in the time.

Advertisements