Thread Synchronization - Event Event, critical section object CriticalSection

Event Event:
base function:
global object: HANDLE g_hEvent
event object is created: g_hEvent the CreateEvent = (NULL, FALSE, FALSE, NULL)
reset state is no signal: the ResetEvent (g_hEvent)
is provided with a status signal: the SetEvent (g_hEvent)
Description:
there are no-signal state signal into the reset may not artificially controlled, preferably automatically set, a plurality of thread requests to the object can be avoided;
only one instance: by creating an event object named by ERROR_ALREADY_EXISTS == GetLastError () carry out;

Critical code segments / critical section object CriticalSection
global object: CRITICAL_SECTION g_cs
Initialization: InitializeCriticalSection (& g_cs)
application ownership: EnterCriticalSection (& g_cs)
release ownership: LeaveCriticalSection (& g_cs)
Cleanup: DeleteCriticalSection (& g_cs)
deadlock: two critical section object can be achieved dead lock: when two threads are not released objects they own, they did not apply the critical area of the object;

Guess you like

Origin www.cnblogs.com/wllwqdeai/p/11317786.html