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. QT解析命令行(QCommandLineOption和QCommandLineParser类)

    Qt从5.2版开始提供了两个类QCommandLineOption和QCommandLineParser来解析应用的命令行参数. 一.命令行写法命令行:"-abc" 在QComma ...

  2. Main Memory Object-Relational Database Management System

    Main Memory Object-Relational Database Management System FastDBMain Memory Relational Database Manag ...

  3. VC 中与字符串相关的宏 _T、TEXT,_TEXT、L 的作用(简单明了)

    一. 在字符串前加一个L作用:    如  L"我的字符串"    表示将ANSI字符串转换成unicode的字符串,就是每个字符占用两个字节.   strlen("as ...

  4. vs2008编译QT开源项目三国杀(五篇文章)

    请参看 http://tieba.baidu.com/f?kz=1508964881 按照上面的网址教程,下载三国杀源码,swig工具,并下载最新的QT4.8.2 for vs2008.我本机已经安装 ...

  5. Lisp: Common Lisp, Racket, Clojure, Emacs Lisp - Hyperpolyglot

    Lisp: Common Lisp, Racket, Clojure, Emacs Lisp - Hyperpolyglot Lisp: Common Lisp, Racket, Clojure, E ...

  6. Functional Jobs // Hire Functional Programmers In Less Time

    Functional Jobs // Hire Functional Programmers In Less Time Hire Functional Programmers Quick Save T ...

  7. oracle数据库、客户端安装以及ps/sql连接和导入表实例

    从下面的网址下载http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098 ...

  8. 关于window.history.back()后退问题

    Windows下的window.history.back()后退后返回的不仅仅是前一个页而是前一个页的状态.假设一个页我改动了3次那必须后退3次才干回到前一个页.并且数据库中删除的数据依旧显示在上面感 ...

  9. Linux命令之rz - 批量上传文件,简单易用(转载)

    用途说明 rz命令能够批量上传文件,当然也可上传单个文件啦.使用的协议是古老的ZMODEM协议,尽管协议古老,但毫不影响的简单易用的特性.一般情 况我们要上传文件到Linux系统,要么使用ftp(还得 ...

  10. Android大图片导致内存问题小结

    在网上看了部分Android中OOM的问题,现在根据理解,做一下笔记. Android OOM 产生的几种原因 1. 程序中使用了太多自己创建的Bitmap. 这种情况通常是最好解决的. 因为你明白你 ...