Windows , . , , 2? , , , . , , (deadlock) .
/* hsem . 2. */
/* 2. */
WaitForSingleObject(hSem, INFINITE);
WaitForSingleObject(hSem, INFINITE);
/* 2. */
ReleaseSemaphore(hSem, 2, &PrevCount);
, , , 2 , . 0. , . .
, CRITI-CAL_SECTION, :
/* 2. */
EnterCriticalSection(&csSem);
WaitForSingleObject(hSem, INFINITE);
WaitForSingleObject(hSem, INFINITE);
LeaveCriticalSection (&csSem);
ReleaseSemaphore(hSem, 2, &PrevCount);
, , . , , , , . , , . , , - .
, WaitForMultipleObjects . . , , , WaitForMultipleObjects . , 1, , .
10.11.
Windows , (atomic multiple-wait operation).