您的位置:首页 > 编程语言 > C语言/C++

blogdown整理c++的多线程编程(资料收集)

2012-11-28 21:03 411 查看


c++的多线程编程(资料收集)

c++的多线程编程

由于现在的标准c++库中没有对多线程的支持,所以如果我们想使用多线程,就是使用其他的库支持。

1)使用windows提供的多线程支持
  中文msdn中查找多线程编程,可以找到。

  http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/_core_multithreading_with_c_and_win32.asp
2)使用MFC提供多线程支持

  中文msdn中查找多线程编程,可以找到。
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vccore/html/_core_multithreading_with_c_and_win32.asp
3)使用boost提供的多线程
http://www.boost.org/doc/html/threads.html 

4)多核程序设计技术——通过软件多线程提升性能(intel出的书)

5)codeproject上C++下的多线程

6) windows核心编程

7)intel :http://shareit.intel.com/WikiHome/Articles/111111287

8)intel:http://shareit.intel.com/WikiHome/Articles/111111284

9)很不错的文档下载:http://www.intel.com/cd/ids/developer/asmo-na/eng/dc/threading/knowledgebase/20439.htm 

10)msdn上所有的线程同步API介绍:http://msdn2.microsoft.com/en-us/library/ms686360.aspx

线程同步API:(来自msdn)
 
Asynchronous functionDescription
APCProcAn application-defined callback function used with theQueueUserAPC function.
GetOverlappedResultRetrieves the results of an overlapped operation.
QueueUserAPCAdds a user-mode asynchronous procedure call (APC) object to the APC queue of the specified thread.
Condition variable and SRW lock functionDescription
AcquireSRWLockExclusiveAcquires a slim reader/writer (SRW) lock in exclusive mode.
AcquireSRWLockSharedAcquires a slim reader/writer (SRW) lock in shared mode.
InitializeConditionVariableInitializes a condition variable.
InitializeSRWLockInitialize a slim reader/writer (SRW) lock.
ReleaseSRWLockExclusiveReleases a slim reader/writer (SRW) lock that was acquired in exclusive mode.
ReleaseSRWLockSharedReleases a slim reader/writer (SRW) lock that was acquired in shared mode.
SleepConditionVariableCSSleeps on the specified condition variable and releases the specified critical section as an atomic operation.
SleepConditionVariableSRWSleeps on the specified condition variable and releases the specified lock as an atomic operation.
WakeAllConditionVariableWake all threads waiting on the specified condition variable.
WakeConditionVariableWake a single thread waiting on the specified condition variable.
Critical-section functionDescription
DeleteCriticalSectionReleases all resources used by an unowned critical section object.
EnterCriticalSectionWaits for ownership of the specified critical section object.
InitializeCriticalSectionInitializes a critical section object.
InitializeCriticalSectionAndSpinCountInitializes a critical section object and sets the spin count for the critical section.
InitializeCriticalSectionExInitializes a critical section object with a spin count and optional flags.
LeaveCriticalSectionReleases ownership of the specified critical section object.
SetCriticalSectionSpinCountSets the spin count for the specified critical section.
TryEnterCriticalSectionAttempts to enter a critical section without blocking.
Event functionDescription
CreateEventCreates or opens a named or unnamed event obje
4000
ct.
CreateEventExCreates or opens a named or unnamed event object and returns a handle to the object.
OpenEventOpens an existing named event object.
PulseEventSets the specified event object to the signaled state and then resets it to the nonsignaled state after releasing the appropriate number of waiting threads.
ResetEventSets the specified event object to the nonsignaled state.
SetEventSets the specified event object to the signaled state.
One-time Initialization functionDescription
InitOnceBeginInitializeBegins one-time initialization.
InitOnceCompleteCompletes one-time initialization.
InitOnceExecuteOnceExecutes the specified function successfully one time. No other threads that specify the same one-time initialization structure can execute this function while it is being executed by the current thread.
InitOnceInitializeInitializes a one-time initialization structure.
Interlocked functionDescription
InterlockedAddPerforms an atomic addition operation on the specifiedLONG values.
InterlockedAdd64Performs an atomic addition operation on the specifiedLONGLONG values.
InterlockedAddAcquirePerforms an atomic addition operation on the specifiedLONG values. The operation is performed with acquire memory access semantics.
InterlockedAddAcquire64Performs an atomic addition operation on the specifiedLONGLONG values. The operation is performed with acquire memory access semantics.
InterlockedAddReleasePerforms an atomic addition operation on the specifiedLONG values. The operation is performed with release memory access semantics.
InterlockedAddRelease64Performs an atomic addition operation on the specifiedLONGLONG values. The operation is performed with release memory access semantics.
InterlockedAndPerforms an atomic AND operation on the specified LONGvalues.
InterlockedAndAcquirePerforms an atomic AND operation on the specified LONGvalues. The operation is performed with acquire memory access semantics.
InterlockedAndReleasePerforms an atomic AND operation on the specified LONGvalues. The operation is performed with release memory access semantics.
InterlockedAnd8Performs an atomic AND operation on the specified charvalues.
InterlockedAnd8AcquirePerforms an atomic AND operation on the specified charvalues. The operation is performed with acquire memory access semantics.
InterlockedAnd8ReleasePerforms an atomic AND operation on the specified charvalues. The operation is performed with release memory access semantics.
InterlockedAnd16Performs an atomic AND operation on the specifiedSHORT values.
InterlockedAnd16AcquirePerforms an atomic AND operation on the specifiedSHORT values. The operation is performed with acquire memory access semantics.
InterlockedAnd16ReleasePerforms an atomic AND operation on the specifiedSHORT values. The operation is performed with release memory access semantics.
InterlockedAnd64Performs an atomic AND operation on the specifiedLONGLONG values.
InterlockedAnd64AcquirePerforms an atomic AND operation on the specifiedLONGLONG values. The operation is performed with acquire memory access semantics.
InterlockedAnd64ReleasePerforms an atomic AND operation on the specifiedLONGLONG values. The operation is performed with release memory access semantics.
InterlockedBitTestAndResetTests the specified bit of the specified LONG value and sets it to 0.
InterlockedBitTestAndReset64Tests the specified bit of the specified LONG64 value and sets it to 0.
InterlockedBitTestAndSetTests the specified bit of the specified LONG value and sets it to 1.
InterlockedBitTestAndSet64Tests the specified bit of the specified LONG64 value and sets it to 1.
InterlockedCompare64Exchange128Performs 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.
InterlockedCompare64ExchangeAcquire128Performs 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.
InterlockedCompare64ExchangeRelease128Performs 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.
InterlockedCompareExchangePerforms 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.
InterlockedCompareExchange64Performs 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.
InterlockedCompareExchangeAcquirePerforms 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.
InterlockedCompareExchangeAcquire64Performs 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.
InterlockedCompareExchangePointerPerforms 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.
InterlockedCompareExchangePointerAcquirePerforms 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.
InterlockedCompareExchangePointerReleasePerforms 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.
InterlockedCompareExchangeReleasePerforms 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.
InterlockedCompareExchangeRelease64Performs 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.
InterlockedDecrementDecrements (decreases by one) the value of the specified 32-bit variable as an atomic operation.
InterlockedDecrement64Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation.
InterlockedDecrementAcquireDecrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with acquire memory access semantics.
InterlockedDecrementAcquire64Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with acquire memory access semantics.
InterlockedDecrementReleaseDecrements (decreases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed with release memory access semantics.
InterlockedDecrementRelease64Decrements (decreases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed with release memory access semantics.
InterlockedExchangeSets a 32-bit variable to the specified value as an atomic operation.
InterlockedExchange64Sets a 64-bit variable to the specified value as an atomic operation.
InterlockedExchangeAcquireSets a 32-bit variable to the specified value as an
fd2a
atomic operation. The operation is performed with acquire memory access semantics.
InterlockedExchangeAcquire64Sets a 32-bit variable to the specified value as an atomic operation. The operation is performed with acquire memory access semantics.
InterlockedExchangeAddPerforms an atomic addition of two 32-bit values.
InterlockedExchangeAdd64Performs an atomic addition of two 64-bit values.
InterlockedExchangeAddAcquirePerforms an atomic addition of two 32-bit values. The operation is performed with acquire memory access semantics.
InterlockedExchangeAddAcquire64Performs an atomic addition of two 64-bit values. The operation is performed with acquire memory access semantics.
InterlockedExchangeAddReleasePerforms an atomic addition of two 32-bit values. The operation is performed with release memory access semantics.
InterlockedExchangeAddRelease64Performs an atomic addition of two 64-bit values. The operation is performed with release memory access semantics.
InterlockedExchangePointerAtomically exchanges a pair of pointer values.
InterlockedExchangePointerAcquireAtomically exchanges a pair of pointer values. The operation is performed with acquire memory access semantics.
InterlockedIncrementIncrements (increases by one) the value of the specified 32-bit variable as an atomic operation.
InterlockedIncrement64Increments (increases by one) the value of the specified 64-bit variable as an atomic operation.
InterlockedIncrementAcquireIncrements (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using acquire memory access semantics.
InterlockedIncrementAcquire64Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using acquire memory access semantics.
InterlockedIncrementReleaseIncrements (increases by one) the value of the specified 32-bit variable as an atomic operation. The operation is performed using release memory access semantics.
InterlockedIncrementRelease64Increments (increases by one) the value of the specified 64-bit variable as an atomic operation. The operation is performed using release memory access semantics.
InterlockedOrPerforms an atomic OR operation on the specified LONGvalues.
InterlockedOrAcquirePerforms an atomic OR operation on the specified LONGvalues. The operation is performed with acquire memory access semantics.
InterlockedOrReleasePerforms an atomic OR operation on the specified LONGvalues. The operation is performed with release memory access semantics.
InterlockedOr8Performs an atomic OR operation on the specified charvalues.
InterlockedOr8AcquirePerforms an atomic OR operation on the specified charvalues. The operation is performed with acquire memory access semantics.
InterlockedOr8ReleasePerforms an atomic OR operation on the specified charvalues. The operation is performed with release memory access semantics.
InterlockedOr16Performs an atomic OR operation on the specified SHORTvalues.
InterlockedOr16AcquirePerforms an atomic OR operation on the specified SHORTvalues. The operation is performed with acquire memory access semantics.
InterlockedOr16ReleasePerforms an atomic OR operation on the specified SHORTvalues. The operation is performed with release memory access semantics.
InterlockedOr64Performs an atomic OR operation on the specifiedLONGLONG values.
InterlockedOr64AcquirePerforms an atomic OR operation on the specifiedLONGLONG values. The operation is performed with acquire memory access semantics.
InterlockedOr64ReleasePerforms an atomic OR operation on the specifiedLONGLONG values. The operation is performed with release memory access semantics.
InterlockedXorPerforms an atomic XOR operation on the specified LONGvalues.
InterlockedXorAcquirePerforms an atomic XOR operation on the specified LONGvalues. The operation is performed with acquire memory access semantics.
InterlockedXorReleasePerforms an atomic XOR operation on the specified LONGvalues. The operation is performed with release memory access semantics.
InterlockedXor8Performs an atomic XOR operation on the specified charvalues.
InterlockedXor8AcquirePerforms an atomic XOR operation on the specified charvalues. The operation is performed with acquire memory access semantics.
InterlockedXor8ReleasePerforms an atomic XOR operation on the specified charvalues. The operation is performed with release memory access semantics.
InterlockedXor16Performs an atomic XOR operation on the specifiedSHORT values.
InterlockedXor16AcquirePerforms an atomic XOR operation on the specifiedSHORT values. The operation is performed with acquire memory access semantics.
InterlockedXor16ReleasePerforms an atomic XOR operation on the specifiedSHORT values. The operation is performed with release memory access semantics.
InterlockedXor64Performs an atomic XOR operation on the specifiedLONGLONG values.
InterlockedXor64AcquirePerforms an atomic XOR operation on the specifiedLONGLONG values. The operation is performed with acquire memory access semantics.
InterlockedXor64ReleasePerforms an atomic XOR operation on the specifiedLONGLONG values. The operation is performed with release memory access semantics.
Mutex functionDescription
CreateMutexCreates or opens a named or unnamed mutex object.
CreateMutexExCreates or opens a named or unnamed mutex object and returns a handle to the object.
OpenMutexOpens an existing named mutex object.
ReleaseMutexReleases ownership of the specified mutex object.
Namespace functionDescription
AddSIDToBoundaryDescriptorAdds a new security identifier (SID) to the specified boundary descriptor.
ClosePrivateNamespaceCloses an open namespace handle.
CreateBoundaryDescriptorCreates a boundary descriptor.
CreatePrivateNamespaceCreates a private namespace.
DeleteBoundaryDescriptorDeletes the specified boundary descriptor.
OpenPrivateNamespaceOpens a private namespace.
Semaphore functionDescription
CreateSemaphoreCreates or opens a named or unnamed semaphore object.
CreateSemaphoreExCreates or opens a named or unnamed semaphore object and returns a handle to the object.
OpenSemaphoreOpens an existing named semaphore object.
ReleaseSemaphoreIncreases the count of the specified semaphore object by a specified amount.
Singly-linked list functionDescription
InitializeSListHeadInitializes the head of a singly linked list.
InterlockedFlushSListFlushes the entire list of items in a singly linked list.
InterlockedPopEntrySListRemoves an item from the front of a singly linked list.
InterlockedPushEntrySListInserts an item at the front of a singly linked list.
QueryDepthSListRetrieves the number of entries in the specified singly linked list.
RtlFirstEntrySListRetrieves the first entry in a singly linked list.
RtlInitializeSListHeadInitializes the head of a singly linked list. Applications should callInitializeSListHead instead.
RtlInterlockedFlushSListFlushes the entire list of items in a singly linked list. Applications should call InterlockedFlushSList instead.
RtlInterlockedPopEntrySListRemoves an item from the front of a singly linked list. Applications should call InterlockedPopEntrySList instead.
RtlInterlockedPushEntrySListInserts an item at the front of a singly linked list. Applications should callInterlockedPushEntrySList instead.
RtlQueryDepthSListRetrieves the number of entries in the specified singly linked list. Applications should call QueryDepthSList instead.
Timer-queue timer functionDescription
ChangeTimerQueueTimerUpdates a timer-queue timer.
CreateTimerQueueCreates a queue for timers.
CreateTimerQueueTimerCreates a timer-queue timer.
DeleteTimerQueueDeletes a timer queue.
DeleteTimerQueueExDeletes a timer queue.
DeleteTimerQueueTimerCancels a timer-queue timer.
Wait functionDescription
MsgWaitForMultipleObjectsWaits until one or all of the specified objects are in the signaled state or the time-out interval elapses. The objects can include input event objects.
MsgWaitForMultipleObjectsExWaits until one or all of the specified objects are in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses. The array of objects can include input event objects.
RegisterWaitForSingleObjectDirects a wait thread in the thread pool to wait on the object.
SignalObjectAndWaitAtomically signals one object and waits on another object.
UnregisterWaitCancels a registered wait operation.
UnregisterWaitExCancels a registered wait operation.
WaitForMultipleObjectsWaits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
WaitForMultipleObjectsExWaits until one or all of the specified objects are in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
WaitForSingleObjectWaits until the specified object is in the signaled state or the time-out interval elapses.
WaitForSingleObjectExWaits until the specified object is in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
WaitOrTimerCallbackAn application-defined function that serves as the starting address for a timer callback or a registered wait callback.
Waitable-timer functionDescription
CancelWaitableTimerSets the specified waitable timer to the inactive state.
CreateWaitableTimerCreates or opens a waitable timer object.
CreateWaitableTimerExCreates or opens a waitable timer object and returns a handle to the object.
OpenWaitableTimerOpens an existing named waitable timer object.
SetWaitableTimerActivates the specified waitable timer.
TimerAPCProcApplication-defined timer completion routine used with theSetWaitableTimer function.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: