[英]Implementation inline assembly of compare and swap function for Sparc V8
My gcc cross compiler doesn't support Built-in functions for atomic memory access . 我的gcc交叉编译器不支持用于原子内存访问的内置函数 。 How i can implement the following function, using inline assembly for Sparc V8 architecture:
如何使用Sparc V8架构的内联汇编实现以下功能:
long __sync_val_compare_and_swap (long *ptr, long oldval long newval)
{
....
}
Those builtin perform an atomic compare and swap. 那些内置函数执行原子比较和交换。 That is, if the current value of *ptr is oldval, then write newval into *ptr.
也就是说,如果* ptr的当前值为oldval,则将newval写入* ptr。
SPARC V8 doesn't have a CAS instruction, so you'll have to emulate it somehow. SPARC V8没有CAS指令,因此您必须以某种方式模拟它。 Eg use the C-like pseudocode for CAS at http://www.oracle.com/technetwork/server-storage/solaris10/index-142944.html and use a static pthread mutex to ensure the atomicity of the atomic {} region.
例如,在http://www.oracle.com/technetwork/server-storage/solaris10/index-142944.html上使用CAS的类似C的伪代码,并使用静态pthread互斥量来确保原子{}区域的原子性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.