1. Atomic operation
Used for synchronization of general single variables.
Lock a variable with the associated API
such as: InterlockedIncrement (&n)
Https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/wdm/nf-wdm-interlockedincrement
2. Critical section is an upgrade lock code block for atomic operations
Between EnterCriticalSection and LeaveCriticalSection
https://msdn.microsoft.com/en-us/library/ms684169 (v=vs.85). aspx
3. Mutex critical zone upgrade for more than one process mutex
CreateMutex Creating locks
OpenMutex Open the lock, which means the other process can't come in.
The ReleaseMutex release lock is not related to the mutex.
Switch back and forth by using WaitForSingleObject.
Way:
When a mutex is created it is in the excited state. That is, the lock is open.
When any one thread process calls the WaitForSingleObject, it returns immediately so that it is in a non-excited state. Indicates being occupied. By the parameters or ReleaseMutex to be released.
Https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=ZH-CN&k=k (mfcapplication1dlg% 2FWaitForSingleObject); K (WaitForSingleObject); K (devlang-c%2b%2b); K (targetos-windows) &rd=true
4. The semaphore is multiple locks can be
5. Event is the most advanced can manually change his excited state and non-excited state. CreateEvent
Https://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=ZH-CN&k=k (mfcapplication1dlg% 2FCreateEventW); K (createeventw); K (devlang-c%2b%2b); K (targetos-windows) &rd=true
Win Thread Synchronization Summary