`

Interlocked Variable Access

阅读更多

Add

AndOrXor

BitTestAndComplementBitTestAndResetBitTestAndSet

CompareExchangeExchangeExchangeAdd

IncrementDecrement,

 

https://msdn.microsoft.com/zh-cn/data/ms684122

https://msdn.microsoft.com/zh-cn/data/ms686360

http://blog.csdn.net/zhongguoren666/article/details/7542975

 

 

Interlocked function Description
InterlockedAdd Performs an atomic addition operation on the specified LONG values.
InterlockedAddAcquire Performs an atomic addition operation on the specified LONG values. The operation is performed with acquire memory ordering semantics.
InterlockedAddRelease Performs an atomic addition operation on the specified LONG values. The operation is performed with release memory ordering semantics.
InterlockedAddNoFence Performs an atomic addition operation on the specified LONG values. The operation is performed atomically, but without using memory barriers
InterlockedAdd64 Performs an atomic addition operation on the specified LONGLONG values.
InterlockedAddAcquire64 Performs an atomic addition operation on the specified LONGLONG values. The operation is performed with acquire memory ordering semantics.
InterlockedAddRelease64 Performs an atomic addition operation on the specified LONGLONG values. The operation is performed with release memory ordering semantics.
InterlockedAddNoFence64 Performs an atomic addition operation on the specified LONGLONG values. The operation is performed atomically, but without using memory barriers
InterlockedAnd Performs an atomic AND operation on the specified LONG values.
InterlockedAndAcquire Performs an atomic AND operation on the specified LONG values. The operation is performed with acquire memory ordering semantics.
InterlockedAndRelease Performs an atomic AND operation on the specified LONG values. The operation is performed with release memory ordering semantics.
InterlockedAndNoFence Performs an atomic AND operation on the specified LONG values. The operation is performed atomically, but without using memory barriers
InterlockedAnd8 Performs an atomic AND operation on the specified char values.
InterlockedAnd8Acquire Performs an atomic AND operation on the specified char values. The operation is performed with acquire memory ordering semantics.
InterlockedAnd8Release Performs an atomic AND operation on the specified char values. The operation is performed with release memory ordering semantics.
InterlockedAnd8NoFence Performs an atomic AND operation on the specified char values. The operation is performed atomically, but without using memory barriers
InterlockedAnd16 Performs an atomic AND operation on the specified SHORT values.
InterlockedAnd16Acquire Performs an atomic AND operation on the specified SHORT values. The operation is performed with acquire memory ordering semantics.
InterlockedAnd16Release Performs an atomic AND operation on the specified SHORT values. The operation is performed with release memory ordering semantics.
InterlockedAnd16NoFence Performs an atomic AND operation on the specified SHORT values. The operation is performed atomically, but without using memory barriers
InterlockedAnd64 Performs an atomic AND operation on the specified LONGLONG values.
InterlockedAnd64Acquire Performs an atomic AND operation on the specified LONGLONG values. The operation is performed with acquire memory ordering semantics.
InterlockedAnd64Release Performs an atomic AND operation on the specified LONGLONG values. The operation is performed with release memory ordering semantics.
InterlockedAnd64NoFence Performs an atomic AND operation on the specified LONGLONG values. The operation is performed atomically, but without using memory barriers
InterlockedBitTestAndComplement Tests the specified bit of the specified LONG value and complements it.
InterlockedBitTestAndComplement64 Tests the specified bit of the specified LONG64 value and complements it. The operation is atomic
InterlockedBitTestAndResetAcquire Tests the specified bit of the specified LONG value and sets it to 0. The operation is atomic, and it is performed with acquire memory ordering semantics
InterlockedBitTestAndResetRelease Tests the specified bit of the specified LONG value and sets it to 0. The operation is atomic, and it is performed using memory release semantics
InterlockedBitTestAndSetAcquire Tests the specified bit of the specified LONG value and sets it to 1. The operation is atomic, and it is performed with acquire memory ordering semantics
InterlockedBitTestAndSetRelease Tests the specified bit of the specified LONG value and sets it to 1. The operation is atomic, and it is performed with release memory ordering semantics
InterlockedBitTestAndReset Tests the specified bit of the specified LONG value and sets it to 0.
InterlockedBitTestAndReset64 Tests the specified bit of the specified LONG64 value and sets it to 0.
InterlockedBitTestAndSet Tests the specified bit of the specified LONG value and sets it to 1.
InterlockedBitTestAndSet64 Tests the specified bit of the specified LONG64 value and sets it to 1.
InterlockedCompare64Exchange128 Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison.
InterlockedCompare64ExchangeAcquire128 Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison. The operation is performed with acquire memory ordering semantics.
InterlockedCompare64ExchangeRelease128 Performs an atomic compare-and-exchange operation on the specified values. The function compares the specified 64-bit values and exchanges with the specified 128-bit value based on the outcome of the comparison. The operation is performed with release memory ordering semantics.
InterlockedCompareExchange Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison.
InterlockedCompareExchangeAcquire Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison. The operation is performed with acquire memory ordering semantics.
InterlockedCompareExchangeRelease Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison. The exchange is performed with release memory ordering semantics.
InterlockedCompareExchangeNoFence Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 32-bit values and exchanges with another 32-bit value based on the outcome of the comparison. The operation is performed atomically, but without using memory barriers
InterlockedCompareExchange64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison.
InterlockedCompareExchangeAcquire64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison. The exchange is performed with acquire memory ordering semantics.
InterlockedCompareExchangeRelease64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison. The exchange is performed with release memory ordering semantics.
InterlockedCompareExchangeNoFence64 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 64-bit values and exchanges with another 64-bit value based on the outcome of the comparison. The operation is performed atomically, but without using memory barriers
InterlockedCompareExchange16 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 16-bit values and exchanges with another 16-bit value based on the outcome of the comparison
InterlockedCompareExchange16Acquire Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 16-bit values and exchanges with another 16-bit value based on the outcome of the comparison. The operation is performed with acquire memory ordering semantics
InterlockedCompareExchange16Release Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 16-bit values and exchanges with another 16-bit value based on the outcome of the comparison. The exchange is performed with release memory ordering semantics
InterlockedCompareExchange16NoFence Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 16-bit values and exchanges with another 16-bit value based on the outcome of the comparison. The operation is performed atomically, but without using memory barriers
InterlockedCompareExchange128 Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified 128-bit values and exchanges with another 128-bit value based on the outcome of the comparison
InterlockedCompareExchangePointer Performs an atomic compare-and-exchange operation on the specified pointer values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison.
InterlockedCompareExchangePointerAcquire Performs an atomic compare-and-exchange operation on the specified pointer values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison. The operation is performed with acquire memory ordering semantics.
InterlockedCompareExchangePointerRelease Performs an atomic compare-and-exchange operation on the specified pointer values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison. The operation is performed with release memory ordering semantics.
InterlockedCompareExchangePointerNoFence Performs an atomic compare-and-exchange operation on the specified values. The function compares two specified pointer values and exchanges with another pointer value based on the outcome of the comparison. The operation is performed atomically, but without using memory barriers
InterlockedDecrement Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation.
InterlockedDecrementAcquire Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with acquire memory ordering semantics.
InterlockedDecrementRelease Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with release memory ordering semantics.
InterlockedDecrementNoFence Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedDecrement16 Decrements (decreases by one) the value of the specified 16-bit variable as an atomic operation
InterlockedDecrement16Acquire Decrements (decreases by one) the value of the specified 16-bit variable as an atomic operation. The operation is performed with acquire memory ordering semantics
InterlockedDecrement16Release Decrements (decreases by one) the value of the specified 16-bit variable as an atomic operation. The operation is performed with release memory ordering semantics
InterlockedDecrement16NoFence Decrements (decreases by one) the value of the specified 16-bit variable as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedDecrement64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation.
InterlockedDecrementAcquire64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with acquire memory ordering semantics.
InterlockedDecrementRelease64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with release memory ordering semantics.
InterlockedDecrementNoFence64 Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedExchange Sets a 32-bit variable to the specified value as an atomic operation.
InterlockedExchangeAcquire Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory ordering semantics.
InterlockedExchangeNoFence Sets a 64-bit variable to the specified value as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedExchange8 Sets an 8-bit variable to the specified value as an atomic operation
InterlockedExchange16 Sets a 16-bit variable to the specified value as an atomic operation.
InterlockedExchange16Acquire Sets a 16-bit variable to the specified value as an atomic operation. The operation is performed using acquire memory ordering semantics
InterlockedExchange16NoFence Sets a 16-bit variable to the specified value as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedExchange64 Sets a 64-bit variable to the specified value as an atomic operation.
InterlockedExchangeAcquire64 Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory ordering semantics.
InterlockedExchangeNoFence64 Sets a 64-bit variable to the specified value as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedExchangePointer Atomically exchanges a pair of pointer values.
InterlockedExchangePointerAcquire Atomically exchanges a pair of pointer values. The operation is performed with acquire memory ordering semantics.
InterlockedExchangePointerNoFence Atomically exchanges a pair of addresses. The operation is performed atomically, but without using memory barriers
InterlockedExchangeSubtract Performs an atomic subtraction of two values.
InterlockedExchangeAdd Performs an atomic addition of two 32-bit values.
InterlockedExchangeAddAcquire Performs an atomic addition of two 32-bit values. The operation is performed with acquire memory ordering semantics.
InterlockedExchangeAddRelease Performs an atomic addition of two 32-bit values. The operation is performed with release memory ordering semantics.
InterlockedExchangeAddNoFence Performs an atomic addition of two 32-bit values. The operation is performed atomically, but without using memory barriers
InterlockedExchangeAdd64 Performs an atomic addition of two 64-bit values.
InterlockedExchangeAddAcquire64 Performs an atomic addition of two 64-bit values. The operation is performed with acquire memory ordering semantics.
InterlockedExchangeAddRelease64 Performs an atomic addition of two 64-bit values. The operation is performed with release memory ordering semantics.
InterlockedExchangeAddNoFence64 Performs an atomic addition of two 64-bit values. The operation is performed atomically, but without using memory barriers
InterlockedIncrement Increments (increases by one) the value of the specified 32-bit variable as an atomic operation.
InterlockedIncrementAcquire Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using acquire memory ordering semantics.
InterlockedIncrementRelease Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using release memory ordering semantics.
InterlockedIncrementNoFence Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedIncrement16 Increments (increases by one) the value of the specified 16-bit variable as an atomic operation
InterlockedIncrement16Acquire Increments (increases by one) the value of the specified 16-bit variable as an atomic operation. The operation is performed using acquire memory ordering semantics
InterlockedIncrement16Release Increments (increases by one) the value of the specified 16-bit variable as an atomic operation. The operation is performed using release memory ordering semantics
InterlockedIncrement16NoFence Increments (increases by one) the value of the specified 16-bit variable as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedIncrement64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation.
InterlockedIncrementAcquire64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using acquire memory ordering semantics.
InterlockedIncrementRelease64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using release memory ordering semantics.
InterlockedIncrementNoFence64 Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed atomically, but without using memory barriers
InterlockedOr Performs an atomic OR operation on the specified LONG values.
InterlockedOrAcquire Performs an atomic OR operation on the specified LONG values. The operation is performed with acquire memory ordering semantics.
InterlockedOrRelease Performs an atomic OR operation on the specified LONG values. The operation is performed with release memory ordering semantics.
InterlockedOrNoFence Performs an atomic OR operation on the specified LONG values. The operation is performed atomically, but without using memory barriers
InterlockedOr8 Performs an atomic OR operation on the specified char values.
InterlockedOr8Acquire Performs an atomic OR operation on the specified char values. The operation is performed with acquire memory ordering semantics.
InterlockedOr8Release Performs an atomic OR operation on the specified char values. The operation is performed with release memory ordering semantics.
InterlockedOr8NoFence Performs an atomic OR operation on the specified char values. The operation is performed atomically, but without using memory barriers
InterlockedOr16 Performs an atomic OR operation on the specified SHORT values.
InterlockedOr16Acquire Performs an atomic OR operation on the specified SHORT values. The operation is performed with acquire memory ordering semantics.
InterlockedOr16Release Performs an atomic OR operation on the specified SHORT values. The operation is performed with release memory ordering semantics.
InterlockedOr16NoFence Performs an atomic OR operation on the specified SHORT values. The operation is performed atomically, but without using memory barriers
InterlockedOr64 Performs an atomic OR operation on the specified LONGLONG values.
InterlockedOr64Acquire Performs an atomic OR operation on the specified LONGLONG values. The operation is performed with acquire memory ordering semantics.
InterlockedOr64Release Performs an atomic OR operation on the specified LONGLONG values. The operation is performed with release memory ordering semantics.
InterlockedOr64NoFence Performs an atomic OR operation on the specified LONGLONG values. The operation is performed atomically, but without using memory barriers
InterlockedXor Performs an atomic XOR operation on the specified LONG values.
InterlockedXorAcquire Performs an atomic XOR operation on the specified LONG values. The operation is performed with acquire memory ordering semantics.
InterlockedXorRelease Performs an atomic XOR operation on the specified LONG values. The operation is performed with release memory ordering semantics.
InterlockedXorNoFence Performs an atomic XOR operation on the specified LONG values. The operation is performed atomically, but without using memory barriers
InterlockedXor8 Performs an atomic XOR operation on the specified char values.
InterlockedXor8Acquire Performs an atomic XOR operation on the specified char values. The operation is performed with acquire memory ordering semantics.
InterlockedXor8Release Performs an atomic XOR operation on the specified char values. The operation is performed with release memory ordering semantics.
InterlockedXor8NoFence Performs an atomic XOR operation on the specified char values. The operation is performed atomically, but without using memory barriers
InterlockedXor16 Performs an atomic XOR operation on the specified SHORT values.
InterlockedXor16Acquire Performs an atomic XOR operation on the specified SHORT values. The operation is performed with acquire memory ordering semantics.
InterlockedXor16Release Performs an atomic XOR operation on the specified SHORT values. The operation is performed with release memory ordering semantics.
InterlockedXor16NoFence Performs an atomic XOR operation on the specified SHORT values. The operation is performed atomically, but without using memory barriers
InterlockedXor64 Performs an atomic XOR operation on the specified LONGLONG values.
InterlockedXor64Acquire Performs an atomic XOR operation on the specified LONGLONG values. The operation is performed with acquire memory ordering semantics.
InterlockedXor64Release Performs an atomic XOR operation on the specified LONGLONG values. The operation is performed with release memory ordering semantics.
InterlockedXor64NoFence Performs an atomic XOR operation on the specified LONGLONG values. The operation is performed atomically, but without using memory barriers
分享到:
评论

相关推荐

    howto_interlocked_circles_use_uncleess_zip_

    interlocked circles code

    .NET中保证线程安全的高级方法Interlocked类使用介绍

    主要介绍了.NET中保证线程安全的高级方法Interlocked类使用介绍,Interlocked类可以为为多个线程共享的变量提供原子操作,需要的朋友可以参考下

    深入多线程之:深入分析Interlocked

    在大多数计算机上,增加变量操作不是一个原子操作,需要执行下列步骤:  一:将实例变量中的值加载到寄存器中。  二:增加或减少该值。  三:在实例变量中存储该值。... Interlocked.Decrement以原子操作的形式递减

    C#使用Interlocked实现线程同步

    今天小编就为大家分享一篇关于C#使用Interlocked实现线程同步,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧

    api-ms-win-core-interlocked-l1-1-0.dll

    api-ms-win-core-interlocked-l1-1-0

    线程同步的6种方式的代码

    常用的线程锁分为一下七种:volatile关键字、Lock锁、System.Threading.Interlocked原子级别操作、Monitor、Metux、ReaderWriterLock、EventWaitHandle同步事件。此次代码中包含了以上除了volatile的测试代码

    Windows下实现的读写锁(VS2008环境)

    WIN环境下实现的轻量级读写锁,效率还过得去,C++代码使用Interlocked系列函数实现。

    C#中使用Interlocked进行原子操作的技巧

    使用.NET提供的Interlocked类可以对一些数据进行原子操作,看起来似乎跟lock锁一样,但它并不是lock锁,它的原子操作是基于CPU本身的,非阻塞的,所以要比lock的效率高

    An SEU-hardened latch with a triple-interlocked structure

    A single event upset (SEU) tolerant latch with a triple-interlocked structure is presented. Its self-recovery mechanism is implemented by using three pairs of guard-gates and inverters to construct ...

    MultiThreadLockDemo.rar

    多线程同步Interlocked。多线程中,部分任务需要进行同步操作,对线程进行加锁操作,确保某个任务A抢到资源进行时,其他任务暂停等待,直到任务完成,其他任务才会顺序执行,类似于线程队列。此时可以使用lock,...

    C# 线程同步的方法

    一、进程内部的线程同步 1、使用lock,用法如下: private static readonly object SeqLock = new ...其在System.Threading命名空间下,Interlocked实际是类控制计数器,从而实现进程的同步,其很容易实现生产者消费

    C#不同锁性能比较

    将C#中的Lock/Monitor/InterLocked用代码示例做性能比较

    高清中文版-mips指令基础

    IPS (an acronym for Microprocessor without Interlocked Pipeline Stages) is a reduced instruction set computer (RISC) instruction set architecture (ISA)[1]:A-1[2]:19 developed by MIPS Technologies ...

    c# 线程(thread)同步处理

    你可以通过Interlocked.Increment 或 Interlocked.Decrement来增加或减少共享变量.它的有点在于是原子操作,也就是说这些方法可以代一个整型的参数增量并且返回新的值,所有的操作就是一步.你也可以使用它来指定变量...

    machanically

    ynthesis of molecular interlocked chains; As the macromolecular version of mechanically interlocked molecules, mechanically interlocked polymers (MIPs) are intriguing candidates for creation of ...

Global site tag (gtag.js) - Google Analytics