Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
CPUID 可用作此处和此处所述的序列化指令。在 C++ 中以这种方式使用它的最小/最简单的 asm 语法是什么?
// Is that enough? // What to do with registers and memory? // Is volatile necessary? asm volatile("CPUID":::);
您是否有理由不使用围栏操作?如果目标是序列化一段代码,您可以执行类似的操作
asm __volatile__ ( " mfence \n" " lfence \n" ); Your code asm __volatile__ ( " mfence \n" " lfence \n" );