High-level Compare And Swap (CAS) functions?

后端 未结 7 1358
清酒与你
清酒与你 2020-12-28 08:43

I\'d like to document what high-level (i.e. C++ not inline assembler ) functions or macros are available for Compare And Swap (CAS) atomic primitives...

E.g., WIN32

相关标签:
7条回答
  • 2020-12-28 09:14

    java has this CAS operation, too

    see here

    there are practical uses for this, like a lock-free hashtable used in multiprocessor system

    0 讨论(0)
  • 2020-12-28 09:15

    On Solaris there is "atomic.h" (i.e. <sys/atomic.h>).

    0 讨论(0)
  • 2020-12-28 09:21

    There have been a series of working group papers on this subject proposing changes to the C++ Standard Library. WG N2427 (C++ Atomic Types and Operations) is the most recent, which contributes to section 29 -- Atomic operations library -- of the pending standard.

    0 讨论(0)
  • 2020-12-28 09:24

    MacOS X has OSAtomic.h

    0 讨论(0)
  • 2020-12-28 09:25

    I'll let others list the various platform-specific APIs, but for future reference in C++09 you'll get the

    atomic_compare_exchange() 
    

    operation in the new "Atomic operations library".

    0 讨论(0)
  • 2020-12-28 09:28

    glib, a common system library on Linux and Unix systems (but also supported on Windows and Mac OS X), defines several atomic operations, including g_atomic_int_compare_and_exchange and g_atomic_pointer_compare_and_exchange.

    0 讨论(0)
提交回复
热议问题