Acquire and Release Semantics

转载 2012年03月29日 11:46:58

Acquire and Release Semantics

1(共 3)对本文的评价是有帮助 评价此主题

An operation has acquire semantics if other processors will always see its effect before any subsequent operation's effect. An operation has release semantics if other processors will see every preceding operation's effect before the effect of the operation itself.

Consider the following code example:

 a++;
 b++;
 c++;

From another processor's point of view, the preceding operations can appear to occur in any order. For example, the other processor might see the increment of b before the increment of a.

Atomic operations, such as those that the InterlockedXxx routines perform, have both acquire and release semantics by default. However, Itanium-based processors execute operations that have only acquire or only release semantics faster than those that have both. Therefore, the system provides InterlockedXxxAcquire and InterlockedXxxRelease versions of some of the InterlockedXxx routines.

For example, the InterlockedIncrementAcquire routine uses acquire semantics to increment a variable. If you rewrote the preceding code example as follows:

 InterlockedIncrementAcquire(&a);
 b++;
 c++;

other processors would always see the increment of a before the increments of b and c.

Likewise, the InterlockedIncrementRelease routine uses release semantics to increment a variable. If you rewrote the code example once again, as follows:

 a++;
 b++;
 InterlockedIncrementRelease(&c);

other processors would always see the increments of a and b before the increment of c.

If the processor does not provide instructions that have only acquire or only release semantics, the system will use the corresponding routine that provides both types of semantics. For example, on x86 processors both InterlockedIncrementAcquire and InterlockedIncrementRelease are equivalent to InterlockedIncrement.

The following table lists the routines that have acquire-only and release-only variants.

InterlockedXxx Routine Acquire-Semantics-Only Version Release-Semantics-Only Version

InterlockedIncrement

InterlockedIncrementAcquire

InterlockedIncrementRelease

InterlockedDecrement

InterlockedDecrementAcquire

InterlockedDecrementRelease

InterlockedCompareExchange

InterlockedCompareExchangeAcquire

InterlockedCompareExchangeRelease

 

 

 

Send comments about this topic to Microsoft

相关文章推荐

Acquire and Release Semantics

关于 Acqurie Semantics 和 Release Semantics 的解释,感觉MSDN上的解释最容易理解: (http://msdn.microsoft.com/en-us/libr...
  • yxc135
  • yxc135
  • 2013-09-13 20:11
  • 1645

volatile, acquire/release, memory fences, and VC2005

One of the more common questions I get about VC2005 code generation relates to the code generation o...

学习load acquire 和store release

这个问题困扰了我很久,一直都想不明白。今天好像有点通了,立即记录下来。仅是个人理解。 在学习BOOST多线程库的原码时 这样一个头文件引起了我的注意: interlocked_read.hpp ...

学习load acquire 和store release

在学习BOOST多线程库的原码时,顺便看了一下它的互斥量basic_timed_mutex的实现方式。它和WINDOWS自身的CriticalSection很相似,唯一不同的就是basic_timed...

[置顶] volatile、内存屏障、Acquire&Release语义 三者的差别和关系(二) —— 之内存屏障

这篇博客是系列文章的第二篇, 主要讲一下内存屏障, 不会讲的很深, 但求明确理解和记住, 什么是内存屏障! 1. 背景知识: CPU乱序执行 这个背景知识很重要, 先讲为快, 在wiki百...

学习load acquire 和store release

这个问题困扰了我很久,一直都想不明白。今天好像有点通了,立即记录下来。仅是个人理解。 在学习BOOST多线程库的原码时 这样一个头文件引起了我的注意: interlocked_read.hpp ...

volatile、内存屏障、Acquire&Release语义 三者的差别和关系(二) —— 之内存屏障

这篇博客是系列文章的第二篇, 主要讲一下内存屏障, 不会讲的很深, 但求明确理解和记住, 什么是内存屏障! 1. 背景知识: CPU乱序执行 这个背景知识很重要, 先讲为快, 在wiki百...

volatile、内存屏障、Acquire&Release语义 三者的差别和关系(一) —— 之volatile

前言: 对于这个题目, 本来想写成一篇博客, 但是写下来发现篇幅有点长, 于是拆分成三篇. volatile 内存屏障 Acquire&Release语义 这三个概念恐怕是做并行编程的时候, 或者...

ora-00054:resource busy and acquire with nowait specified解决方法

当某个数据库用户在数据库中插入、更新、删除一个表的数据,或者增加一个表的主键时或者表的索引时,常常会出现ora-00054:resource busy and acquire with nowait ...

ora-00054:resource busy and acquire with nowait specified解决方法

ora-00054:resource busy and acquire with nowait specified解决方法 当某个数据库用户在数据库中插入、更新、删除一个表的数据,或者增加一个表...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)