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 ...
随机推荐
- 序列化TList of objects(摘自danieleteti的网站)
Some weeks ago a customer asked to me if it is possibile serialize a TList of objects. “Hey, you sho ...
- IE浏览器上传文件时本地路径变成”C:\fakepath\”的问题
在使用<input id="file_upl" type="file" />控件上传文件时,有时会需要获取文件本地路径展示给客户,这时可以通过这样的 ...
- Mysql 和Oracle rows 区别
mysql> explain select t1.* from t2 ,t1 where t2.id=t1.id and t2.id<3;\ +----+-------------+--- ...
- win 7 设置防火墙例外的端口号, 让其域网中可以访问
背景,发布 一个tomcat下的website, 而发局域网可以访问. 这时,可以关闭防火墙:或者开启防火墙,并设置一个防火墙的入站规则,让身边的同事访问这个website. 设置方法:win 7 - ...
- Delphi 中TWebBrowser的扩展控件TExWebBrowser
主要扩展了3D界面.右键菜单.是否显示图片.是否支持JAVA等功能. 代码如下: unit ExtWebBrowser; interface uses Windows, SysUtils, Class ...
- C++经典笔试题及参考答案-趋势科技
1.static有什么用途?(请至少说明两种) 答案:1)在函数体,一个被声明为静态的变量在这一函数被调用过程中维持其值不变. 2)在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所用函数 ...
- 一个好用的Dialog插件
网页中常常须要弹出dialog,尽管非常多JS开源框架都提供这个功能,可是效果都不是非常好,比方easy-UI.改动样式这些又不是我擅长的,身边又没有美工兄弟,苦逼啊! (Easy-UI的BasicD ...
- 千万别用模板给的list.size()巨坑
要用!list.empty()取代i<list.size();否则就不会AC了.
- 基于Servlet、JSP、JDBC、MySQL的一个简单的用户注冊模块(附完整源代码)
近期看老罗视频,做了一个简单的用户注冊系统.用户通过网页(JSP)输入用户名.真名和password,Servlet接收后通过JDBC将信息保存到MySQL中.尽管是个简单的不能再简单的东西,但麻雀虽 ...
- CC 3-Palindromes(manacher)
传送门:3-Palindromes 题意:求为回文串且能整除3且不前导0的子串个数. 分析:由 manacher算法O(N)可算出以i为坐标的最长为p[i]回文子串,且Si-k,Si-k+1..... ...