C ++ 11标准是否正式定义了获取,释放和消费操作? [英] Does the C++11 standard formally define acquire, release, and consume operations?
问题描述
在C ++ 11标准中,1.10 / 5节提到,但没有正式定义术语获取操作
, code>和
消费操作
。然后在第29节中继续使用这些术语来描述某些内存排序,原子操作和内存栅栏的操作。例如,订单和一致性中的29.3 / 1表示:
In the C++11 standard, section 1.10/5 mentions, but does not formally define the terms acquire operation
, release operation
, and consume operation
. It then goes on in Section 29 to use these terms to describe the actions of certain memory orderings, atomic operations, and memory fences. For instance, 29.3/1 on "Order and Consistency" states:
memory_order_release , memory_order_acq_rel 和 memory_order_seq_cst :存储操作对受影响的内存位置执行释放操作 [强调添加]。
memory_order_release, memory_order_acq_rel, and memory_order_seq_cst: a store operation performs a release operation [emphasis added] on the affected memory location.
这种类型的语言在第29节中被重复,但是它让我感到烦恼, memory_order
枚举的所有含义都是基于
This type of language is repeated throughout section 29, but it bothers me a bit that all meanings for the memory_order
enumerations are based on operation types that themselves do not seem to be formalized by the standard, yet must have some commonly agreed-to meaning for them to be effective as definitions.
使用不同的方法来实现自定义操作类型,它们本身似乎不被标准正式化,但必须具有一些共同的含义,以使它们作为定义有效。 ,如果我说一个条是一个翻转的foo, bar 和 foo 的具体含义是不明确的,因为这两个术语都没有正式定义。
Put a different way, if I said "A bar is a flipped foo", the concrete meaning of bar and foo are ambiguous since neither term is formally defined. Only their relative natures are defined.
C ++ 11标准或其他C ++ 11标准委员会文件是否正式定义了一个获取操作
,发布操作
等,或者是这些简单的通常理解的术语?如果后者,是否有一个好的参考,被认为是这些操作的意义的行业标准?我特别问,因为硬件内存一致性模型不是相等的,因此我想要有一些通常同意的参考,允许实现编译器等正确地将这些操作的语义转换为本机汇编命令。 / p>
Does the C++11 standard, or some other C++11 standards committee document formally define what exactly an acquire operation
, release operation
, etc. is, or are these simply commonly understood terms? If the latter, is there a good reference that is considered an industry standard for the meaning of these operations? I specifically ask because hardware memory consistency models are not created equal, and therefore I'm figuring there must be some commonly agreed-to reference that allows those implementing compilers, etc. to properly translate the semantics of these operations into native assembly commands.
推荐答案
在其中一个注释中有一个非正式的汇总定义:
There's an informal summarized definition given in one of the notes:
在上执行发布操作A
强制对其他内存位置的先前副作用变为对其他线程可见,以后执行消耗或获取操作
performing a release operation on
A
forces prior side effects on other memory locations to become visible to other threads that later perform a consume or an acquire operation onA
.
除此之外,获取和释放操作的行为在1.10中完全定义,特别是它们如何促成发生在之前的关系。除了行为之外的任何定义都是无用的。
Besides that, the behavior of acquire and release operations is fully defined in 1.10, specifically in how they contribute to happens-before relationships. Any definition apart from behavior is useless.
这篇关于C ++ 11标准是否正式定义了获取,释放和消费操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!