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
  • 1710

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

学习笔记:acquire-release初步理解

#include #include #include #include #include #include #include using namespace std; atomic g...
  • audi2
  • audi2
  • 2014年09月26日 18:01
  • 286

学习load acquire 和store release

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

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

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

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

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

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

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

解决锁的问题—-ORA-00054: resource busy and acquire with NOWAIT specified

天开发人员在做同步时,出现如下错误: Fri Feb 15 23:57:15 2011 Errors in file /ora10/admin/crmiba/bdump/crmiba_j003_1...
  • gyanp
  • gyanp
  • 2011年09月06日 10:13
  • 2291

解决办法:resource busy and acquire with nowait specified

ora-00054:resource busy and acquire with nowait specified解决方法 当某个数据库用户在数据库中插入、更新、删除一个表的数据,或者增加一个表...
  • skate29
  • skate29
  • 2014年07月15日 19:29
  • 416

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

当某个数据库用户在数据库中插入、更新、删除一个表的数据,或者增加一个表的主键时或者表的索引时,常常会出现ora-00054:resource busy and acquire with nowai...
  • snihcel
  • snihcel
  • 2012年10月16日 15:35
  • 580
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Acquire and Release Semantics
举报原因:
原因补充:

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