Acquire and Release Semantics
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 |
Acquire and Release Semantics的更多相关文章
- Python用上锁和解锁 lock lock.acquire lock.release 模拟抢火车票
Python用上锁和解锁 lock lock.acquire lock.release 模拟抢火车票 import jsonimport timefrom multiprocessing impor ...
- Acquire and Release Fences
转载自: http://preshing.com/20130922/acquire-and-release-fences/ Acquire and release fences, in my op ...
- Lock 深入理解acquire和release原理源码及lock独有特性acquireInterruptibly和tryAcquireNanos
https://blog.csdn.net/sophia__yu/article/details/84313234 Lock是一个接口,通常会用ReentrantLock(可重入锁)来实现这个接口. ...
- C# Development 13 Things Every C# Developer Should Know
https://dzone.com/refcardz/csharp C#Development 13 Things Every C# Developer Should Know Written by ...
- [译]Memory Reordering Caught in the Act
原文:http://preshing.com/20120515/memory-reordering-caught-in-the-act/ 编写lock-free的C/C++程序时,在保证memory ...
- C/C++ Volatile关键词深度剖析(转)
本文转载自博文C/C++ Volatile关键词深度剖析. 背景 前几天,发了一条如下的微博 (关于C/C++ Volatile关键词的使用建议): 此微博,引发了朋友们的大量讨论:赞同者有之:批评者 ...
- Game Engine Architecture 5
[Game Engine Architecture 5] 1.Memory Ordering Semantics These mysterious and vexing problems can on ...
- c++Volatile关键词
看到的一篇文章觉得还不错吧,文章具体位置也找不到了,复制一下,留着日后复习 背景 此微博,引发了朋友们的大量讨论:赞同者有之:批评者有之:当然,更多的朋友,是希望我能更详细的解读C/C++ Volat ...
- C/C++ Volatile关键词深度剖析
文章来源:http://hedengcheng.com/?p=725 背景 此微博,引发了朋友们的大量讨论:赞同者有之:批评者有之:当然,更多的朋友,是希望我能更详细的解读C/C++ Volatile ...
随机推荐
- Android高手进阶——Adapter深入理解与优化
Android高手进阶--Adapter深入理解与优化 通常是针对包括多个元素的View,如ListView,GridView.ExpandableListview,的时候我们是给其设置一个Adapt ...
- 积累的VC编程小技巧之工具提示
1.用鼠标移动基于对话框的无标题栏程序的简单方法 void CVCTestDlg::OnLButtonDown(UINT nFlags, CPoint point) { //一句话解决问题 ...
- ActiveX控件的安全初始化和脚本操作 和 数字签名SIGN
摘要:数字签名SIGN保证控件在下载时候的安全性.如果你的代码已经经过数字签名,即使用户IE的安全设置很高也能下载,安装并登记.但是在页面上初始化,或者用脚本运行这个控件,为了保证安全性,还需要进行M ...
- C++中的对象指针
指向对象的指针 在建立对象的时候,变异系统会给每一个对象分配一定的存储空间,以存放其成员. 对象空间的起始地址就是对象的指针.可以定义一个指针变量,用来存放对象的指针. 一个简单的示例1.1: #in ...
- windows下eclipse跑junit报错:CreateProcess error=206
from:http://isuifengfei.iteye.com/blog/1684262 windows下,eclipse中运行junit出现错误提示: Exception occurred ex ...
- SilkTest高级进阶系列10 – bitmap工具bitview
SilkTest 提供了一个bitmap的工具,它可以帮助我们捕捉,比较bitmap文件.该bitmap工具的位置是~/SilkTest/bitview.exe 运行该工具后,你会发现它提供了捕捉控件 ...
- hdu Crazy Circuits
Crazy Circuits 题目: 给出一个电路板,从+极出发到负极. 如今给你电路板上的最小电流限制,要你在电流平衡的时候求得从正极出发的最小电流. 算法: 非常裸的有源汇最小流.安有源汇最大流做 ...
- 区间Dp 暴力枚举+动态规划 Hdu1081
F - 最大子矩形 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Status Des ...
- OCA读书笔记(13) - 性能管理
使用EM监控性能使用自动内存管理(AMM)使用Memory Advisor分配内存查看性能相关动态视图诊断无效的和不可用的对象 创建问题SQLsqlplus / as sysdbaconn scott ...
- ANSI Common Lisp 中文翻譯版 — ANSI Common Lisp 中文版
ANSI Common Lisp 中文翻譯版 — ANSI Common Lisp 中文版 ANSI Common Lisp 中文翻譯版¶