多线程(C++)WIN API 互锁函数
标签:
多线程winapi互锁函数杂谈 |
分类: 多线程 |
一 互锁函数
互锁函数的家族十分的庞大,可以查看msdn(http://msdn2.microsoft.com/en-us/library/ms686360.aspx)以InterLocked开始的函数都是户数函数。使用互锁函数的优点是:他的速度要比其他的CriticalSection,Mutex,Event,Semaphore快很多。
二 简单实例
使用一些实例说明部分互锁函数的使用:
1) LONG InterlockedExchangeAdd(
PLONG plAddend,LONG Increment);
简 单实例,在线程函数中对全局的变量自增,在开始使其为0,在线程都执行完以后输出全局变量的值,如果我们不使用互锁函数,则最后输出的结果,大部分情况是 不正确的,比如我们一共有10000个线程的话,则全局变量的值一般是比10000要小;但是如果我们使用互锁函数来实现自增,则就快速的实现了线程安 全,最后输出的全局变量一定是10000.
在上面的代码中使用了//InterlockedExchangeAdd(reinterpret_cast<long*>(&g_x),1); 来实现g_x的线程安全的自增。
2)使用LONG InterlockedExchange(PLONG plTarget,LONG lValue);实现循环锁:
三 互锁函数列表
一般的互锁函数:
链表的互锁函数:
二 简单实例
1) LONG InterlockedExchangeAdd(
简 单实例,在线程函数中对全局的变量自增,在开始使其为0,在线程都执行完以后输出全局变量的值,如果我们不使用互锁函数,则最后输出的结果,大部分情况是 不正确的,比如我们一共有10000个线程的话,则全局变量的值一般是比10000要小;但是如果我们使用互锁函数来实现自增,则就快速的实现了线程安 全,最后输出的全局变量一定是10000.
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI 互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />#include <windows.h>
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />#include <process.h>
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />#include <stdio.h>
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> #define THREAD_MAX 100000
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> int g_x = 0;
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />unsigned __stdcall ThreadEntity( void * pVoid)
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> {
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> g_x ++;
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> //InterlockedExchangeAdd(reinterpret_cast<long*>(&g_x),1);
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> return 1;
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />}
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> int main()
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> {
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> HANDLE hth[THREAD_MAX];
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> unsigned uiThreadID[THREAD_MAX];
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> printf( "start create children threadings:\n ");
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> for(int i = 0; i < THREAD_MAX; ++i)
http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> {
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> hth[i] = (HANDLE)_beginthreadex( NULL, // security
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> 0, // stack size
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> ThreadEntity,
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> ( void*)&i, // arg list
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> 0,
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> &uiThreadID[i] );
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> if ( hth[i] == 0 )
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> printf( "Failed to create thread 1\n ");
http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> }
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> WaitForMultipleObjects( THREAD_MAX, hth, true,10000);
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> for(int i = 0; i <THREAD_MAX; ++i)
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> CloseHandle( hth[i] );
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> printf( "last: g_x is %d\n ",g_x);
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> printf( "Primary thread terminating.\n ");
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />}
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gifAPI
在上面的代码中使用了
2)使用LONG InterlockedExchange(PLONG plTarget,LONG lValue);实现循环锁:
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI 互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />// Global variable indicating whether a shared resource is in use or not
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> BOOL g_fResourceInUse = FALSE;
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> void Func1()
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> {
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> //Wait to access the resource.
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> while(InterlockedExchange(&g_fResourceInUse, TRUE) == TRUE)
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> Sleep( 0);
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> //Access the resource.
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> 
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> //We no longer need to access the resource.
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" /> InterlockedExchange( &g_fResourceInUse, FALSE);
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />}
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI互锁函数" TITLE="多线程(C++)WIN API 互锁函数" />
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI

http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI

http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/InBlock.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gifAPI
http://www.cppblog.com/Images/OutliningIndicators/None.gifAPI
三 互锁函数列表
一般的互锁函数:
| Interlocked function | Description |
|---|---|
| InterlockedAdd | Performs an atomic addition operation on the specified LONG values. |
| InterlockedAdd64 | Performs an atomic addition operation on the specified LONGLONG values. |
| InterlockedAddAcquire | Performs an atomic addition operation on the specified LONG values. The operation is performed with acquire memory access semantics. |
| InterlockedAddAcquire64 | Performs an atomic addition operation on the specified LONGLONG values. The operation is performed with acquire memory access semantics. |
| InterlockedAddRelease | Performs an atomic addition operation on the specified LONG values. The operation is performed with release memory access semantics. |
| InterlockedAddRelease64 | Performs an atomic addition operation on the specified LONGLONG values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedAndRelease | Performs an atomic AND operation on the specified LONG values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedAnd8Release | Performs an atomic AND operation on the specified char values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedAnd16Release | Performs an atomic AND operation on the specified SHORT values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedAnd64Release | Performs an atomic AND operation on the specified LONGLONG values. The operation is performed with release memory access semantics. |
|
InterlockedBitTestAndRes |
Tests the specified bit of the specified LONG value and sets it to 0. |
|
InterlockedBitTestAndRes |
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. |
|
InterlockedBitTestAndSet |
Tests the specified bit of the specified LONG64 value and sets it to 1. |
|
InterlockedCompare64Exch |
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. |
|
InterlockedCompare64Exch |
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 access semantics. |
|
InterlockedCompare64Exch |
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 access semantics. |
|
InterlockedCompareExchan |
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. |
|
InterlockedCompareExchan |
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. |
|
InterlockedCompareExchan |
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 access semantics. |
|
InterlockedCompareExchan |
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 access semantics. |
|
InterlockedCompareExchan |
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. |
|
InterlockedCompareExchan |
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 access semantics. |
|
InterlockedCompareExchan |
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 access semantics. |
|
InterlockedCompareExchan |
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 access semantics. |
|
InterlockedCompareExchan |
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 access semantics. |
| InterlockedDecrement | Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. |
| InterlockedDecrement64 | Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. |
|
InterlockedDecrementAcqu |
Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with acquire memory access semantics. |
|
InterlockedDecrementAcqu |
Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with acquire memory access semantics. |
|
InterlockedDecrementRele |
Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with release memory access semantics. |
|
InterlockedDecrementRele |
Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with release memory access semantics. |
| InterlockedExchange | Sets a 32-bit variable to the specified value as an atomic operation. |
| InterlockedExchange64 | Sets a 64-bit variable to the specified value as an atomic operation. |
|
InterlockedExchangeAcqui |
Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory access semantics. |
|
InterlockedExchangeAcqui |
Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory access semantics. |
| InterlockedExchangeAdd | Performs an atomic addition of two 32-bit values. |
|
InterlockedExchangeAdd64 |
Performs an atomic addition of two 64-bit values. |
|
InterlockedExchangeAddAc |
Performs an atomic addition of two 32-bit values. The operation is performed with acquire memory access semantics. |
|
InterlockedExchangeAddAc |
Performs an atomic addition of two 64-bit values. The operation is performed with acquire memory access semantics. |
|
InterlockedExchangeAddRe |
Performs an atomic addition of two 32-bit values. The operation is performed with release memory access semantics. |
|
InterlockedExchangeAddRe |
Performs an atomic addition of two 64-bit values. The operation is performed with release memory access semantics. |
|
InterlockedExchangePoint |
Atomically exchanges a pair of pointer values. |
|
InterlockedExchangePoint |
Atomically exchanges a pair of pointer values. The operation is performed with acquire memory access semantics. |
| InterlockedIncrement | Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. |
| InterlockedIncrement64 | Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. |
|
InterlockedIncrementAcqu |
Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using acquire memory access semantics. |
|
InterlockedIncrementAcqu |
Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using acquire memory access semantics. |
|
InterlockedIncrementRele |
Increments (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using release memory access semantics. |
|
InterlockedIncrementRele |
Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using release memory access semantics. |
| 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 access semantics. |
| InterlockedOrRelease | Performs an atomic OR operation on the specified LONG values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedOr8Release | Performs an atomic OR operation on the specified char values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedOr16Release | Performs an atomic OR operation on the specified SHORT values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedOr64Release | Performs an atomic OR operation on the specified LONGLONG values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedXorRelease | Performs an atomic XOR operation on the specified LONG values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedXor8Release | Performs an atomic XOR operation on the specified char values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedXor16Release | Performs an atomic XOR operation on the specified SHORT values. The operation is performed with release memory access semantics. |
| 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 access semantics. |
| InterlockedXor64Release | Performs an atomic XOR operation on the specified LONGLONG values. The operation is performed with release memory access semantics. |
链表的互锁函数:
| Singly-linked list function | Description |
|---|---|
| InitializeSListHead | Initializes the head of a singly linked list. |
| InterlockedFlushSList | Flushes the entire list of items in a singly linked list. |
|
InterlockedPopEntrySList |
Removes an item from the front of a singly linked list. |
|
InterlockedPushEntrySLis |
Inserts an item at the front of a singly linked list. |
| QueryDepthSList | Retrieves the number of entries in the specified singly linked list. |
| RtlFirstEntrySList | Retrieves the first entry in a singly linked list. |
| RtlInitializeSListHead | Initializes the head of a singly linked list. Applications should call InitializeSListHead instead. |
|
RtlInterlockedFlushSList |
Flushes the entire list of items in a singly linked list. Applications should call InterlockedFlushSList instead. |
|
RtlInterlockedPopEntrySL |
Removes an item from the front of a singly linked list.
Applications should call InterlockedPopEntrySList |
|
RtlInterlockedPushEntryS |
Inserts an item at the front of a singly linked list.
Applications should call InterlockedPushEntrySLis |
| RtlQueryDepthSList | Retrieves the number of entries in the specified singly linked list. Applications should call QueryDepthSList instead. |

加载中…