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的更多相关文章

  1. Python用上锁和解锁 lock lock.acquire lock.release 模拟抢火车票

    Python用上锁和解锁  lock lock.acquire lock.release 模拟抢火车票 import jsonimport timefrom multiprocessing impor ...

  2. Acquire and Release Fences

    转载自:   http://preshing.com/20130922/acquire-and-release-fences/ Acquire and release fences, in my op ...

  3. Lock 深入理解acquire和release原理源码及lock独有特性acquireInterruptibly和tryAcquireNanos

    https://blog.csdn.net/sophia__yu/article/details/84313234 Lock是一个接口,通常会用ReentrantLock(可重入锁)来实现这个接口. ...

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

  5. [译]Memory Reordering Caught in the Act

    原文:http://preshing.com/20120515/memory-reordering-caught-in-the-act/ 编写lock-free的C/C++程序时,在保证memory  ...

  6. C/C++ Volatile关键词深度剖析(转)

    本文转载自博文C/C++ Volatile关键词深度剖析. 背景 前几天,发了一条如下的微博 (关于C/C++ Volatile关键词的使用建议): 此微博,引发了朋友们的大量讨论:赞同者有之:批评者 ...

  7. Game Engine Architecture 5

    [Game Engine Architecture 5] 1.Memory Ordering Semantics These mysterious and vexing problems can on ...

  8. c++Volatile关键词

    看到的一篇文章觉得还不错吧,文章具体位置也找不到了,复制一下,留着日后复习 背景 此微博,引发了朋友们的大量讨论:赞同者有之:批评者有之:当然,更多的朋友,是希望我能更详细的解读C/C++ Volat ...

  9. C/C++ Volatile关键词深度剖析

    文章来源:http://hedengcheng.com/?p=725 背景 此微博,引发了朋友们的大量讨论:赞同者有之:批评者有之:当然,更多的朋友,是希望我能更详细的解读C/C++ Volatile ...

随机推荐

  1. 《学习opencv》笔记——矩阵和图像处理——cvMinManLoc,cvMul,cvNot,cvNorm and cvNormalize

    矩阵和图像的操作 (1)cvMinManLoc函数 其结构 void cvMinMaxLoc(//取出矩阵中最大最小值 const CvArr* arr,//目标矩阵 double* min_val, ...

  2. 断剑重铸之日,席卷朗朗乾坤之时--PHP学习一月漫记

    传说中阿尔萨斯王子沉沦堕落之后,被巫妖王安置在冰冷的城堡中,静静地等待重出天日,它随身携带的宝剑也埋没与尘土之间,暗淡无光.他想起宝剑伴身,东征西战的峥嵘岁月,忆及如今身陷囹圄,一股怨念由心底升起,许 ...

  3. vlan 以及 Linux实现的IEEE 802.1Q VLAN

    vlan 以及 Linux实现的IEEE 802.1Q VLAN Vlan的概念 VLAN技术介绍 VLANVLAN概述 以太网是一种基于CSMA/CD(Carrier Sense Multiple ...

  4. WiPlug_百度百科

    WiPlug_百度百科 WiPlug

  5. ZeroClipboard插件:兼容各浏览器网页复制功能

    常规利用JS编写的网页复制功能只对IE有效,无法做到兼容其它浏览器,代码如下: function copyToClipBoard(){ var clipBoardContent="" ...

  6. SVNKit getFileFromSVN

    /* * ==================================================================== * Copyright (c) 2004-2011 ...

  7. 北京哪儿有卖tods豆豆鞋的?在线等答案、、、、(类似动物园、西单等地)_百度知道

    北京哪儿有卖tods豆豆鞋的?在线等答案....(类似动物园.西单等地)_百度知道 北京哪儿有卖tods豆豆鞋的?在线等答案....(类似动物园.西单等地)

  8. hdu1116--解题报告--初步了解欧拉回路

    由题目意思..我们只要把n个字符串的首尾字母看作是点,这个字符串看着边来处理就可以啦...将题目的案例图形化如下: 那么接着就是欧拉路径和欧拉回路判断,我们这里用并査集来判断图是不是连通的,然后根据有 ...

  9. HashTable的数组和连接两种实现方法(Java版本号)

    1.散列表的接口类 package cn.usst.hashtable; /** * 散列表的接口类 * @author G-Xia * */ public interface HashTable { ...

  10. ONVIFclient搜索设备获取rtsp解决开发笔记(精华文章)

    总结:           眼下ONVIF协议系列设备已经超过一半的数字监控行业占据更多,关闭,作为一个开发者,你还在犹豫下就明白了?本文介绍了ONVIFclient从搜索,认证,获取,媒体信息获取. ...