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 ...
随机推荐
- ConnectivityManager
ConnectivityManager 主要管理网络连接的相关的类它主要负责的是1 监视网络连接状态 包括(Wi-Fi, GPRS, UMTS, etc)2 当网络状态改变时发送广播通知3 当网络连接 ...
- <一年成为Emacs高手>更新到20130706版
这次更新比较多,加了第三方精品插件推荐,添加了我认为不错的Emacs社区. 见 原文
- 管道实现进程间通讯 、WaitNamedPipe
一.管道实现进程间通讯 主要的理论知识 1.什么是管道以及分类 管道是两个头的东西,每一个头各连接一个进程或者同一个进程的不同代码,依照管道的类别分有两种管道,匿名的和命名的:依照管道的传输方向分也能 ...
- Php 解析XML文件
Php 解析XML文件 Php 解析XML文件,仅供学习參考!演示样例代码例如以下: <?php header("Content-type: text/html; charset=ut ...
- VirtualBox集群建立和网络配置
安装 1. 安装 安装Oracle VM VirtualBox之后,新建一个虚拟机,制定好内存等信息,开始安装操作系统,这里安装ubuntu-12.04.2-desktop-i386版本. 2. 拷贝 ...
- 它们的定义Adapterg在etView( )正在使用View.setTag()与不同的是不使用。
首先看使用Tag案件. @Override public View getView(int position, View view, ViewGroup group) { ViewHolder hol ...
- discuz清空session,导致session保存机制失败,session无法更新与解决
<?php function userErrorHandler() { $e = func_get_args(); echo '<pre style="color:red;&qu ...
- hdu Crazy Circuits
Crazy Circuits 题目: 给出一个电路板,从+极出发到负极. 如今给你电路板上的最小电流限制,要你在电流平衡的时候求得从正极出发的最小电流. 算法: 非常裸的有源汇最小流.安有源汇最大流做 ...
- hdu 3309 Roll The Cube ( bfs )
Roll The Cube Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- Cocos2d-x-lua游戏两个场景互相切换MainScene01切换到MainScene02
/* 场景一lua代码 */ require "MainScene02" local dic_size = CCDirector:sharedDirector():getWinSi ...