I need atomic operation code equivalent to following:
__asm__ __volatile__ (
" lock;\n"
" addl %1, %0; \n"
" movl %0, %%eax"
: "=m"(a), "=a" (c)
开发者_Go百科 : "ir"(b)
);
(Adding two variables a and b and output stored in both a and c on Linux)
Equivalent to above is needed on Solaris(Sparc architecture). Is there anyone to help me out?
This article should answer all of your questions in depth and even provides code: http://developers.sun.com/solaris/articles/atomic_sparc/
You may need to re-format it a little in terms of inline assembly, but other than that, should be good to go.
精彩评论