gpt4 book ai didi

c++ - 对原子操作的最低要求

转载 作者:太空宇宙 更新时间:2023-11-04 06:06:04 25 4
gpt4 key购买 nike

我只是想收集一些关于原子操作要求的基于证据的信息。

例如(可能不对,举个例子)

  1. at x86_64, when you write or read on the entry sizeof long and aligned by long, the operation is aotmic,because balabalabala ...

  2. at x86_64, when you write or read bytes use gcc atomic primitive, your operation on these bytes will keep atomic.

希望收到和帮助:)

最佳答案

引自 Professional C++ :

A simple assignment to a simple scalar variable typically requires no synchronization. For example, on the x86, a 32-bit aligned value is handled atomically at the hardware level and a single transaction requires no explicit synchronization. For example, setting a Boolean value to false to stop a thread requires no synchronization, but an operation like ++, -- or op= for any given op requires synchronization.

这并没有回答您所有的问题,但这就是您要寻找的部分内容吗?

关于c++ - 对原子操作的最低要求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10274189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com