高级比较和交换 (CAS) 功能?

发布于 2024-07-05 16:21:03 字数 173 浏览 7 评论 0原文

我想记录哪些高级(即 C++ 不是内联汇编程序)函数或宏可用于比较和交换 (CAS) 原子原语...

例如,x86 上的 WIN32 有一系列函数_InterlockedCompareExchange<_intrin.h> 标头中的 code>。

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 on x86 has a family of functions _InterlockedCompareExchange in the <_intrin.h> header.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

旧时浪漫 2024-07-12 16:21:03

glib 是 Linux 和 Unix 系统上的通用系统库(但也支持 Windows 和 Mac OS X),定义了 几个原子操作,包括g_atomic_int_compare_and_exchangeg_atomic_pointer_compare_and_exchange

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.

无敌元气妹 2024-07-12 16:21:03

我将让其他人列出各种特定于平台的 API,但为了将来在 C++09 中参考,您将

atomic_compare_exchange() 

在新的“原子操作库”中获得操作。

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".

遗心遗梦遗幸福 2024-07-12 16:21:03

java有这个CAS操作,也

参见这里

对此有实际用途,例如 多处理器系统中使用的无锁哈希表

java has this CAS operation, too

see here

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

不再让梦枯萎 2024-07-12 16:21:03

在 Solaris 上有“atomic.h”(即 )。

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

梦在夏天 2024-07-12 16:21:03

MacOS X 有 OSAtomic.h

MacOS X has OSAtomic.h

倒带 2024-07-12 16:21:03

已经有一系列关于此主题的工作组论文建议对 C++ 标准库进行更改。 WG N2427 C++ 原子类型和操作(C++ 原子类型和操作)是最新的,它为待定标准的第 29 节(原子操作库)做出了贡献。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文