Windows, , , Critical_Section, . , Windows :
1) InitializeCriticalSection (p);
2) EnterCriticalSection (p);
3) TryEnterCriticalSection (p);
4) LeaveCriticalSection (p);
5) DeleteCriticalSection (p).
, Critical_Section. , , .
, , . .
. , , , .
Critical_Section , . , InitializeCriticalSection. , 2. . . , LeaveCriticalSection.
CS , , DeleteCriticalSection.
Critical_Section , , , . , . , , .
.
, , Windows Mutex.
, , . , , , . , . , . , . FIFO, , . , - , , . , , .
|
|
CreateMutex, :
CreateMutex (p1, p2, p3);
p1 ;
p2 ;
p3 .
p1 NULL . , .
p2 == true, , . . p2 == false, .
p3 , , . , . , . p3 . .
CreateMutex , . .
p3 , CreateMutex , GetLastError, CreateMutex, ERROR_ALREADY_EXISTS.
, , , ReleaseMutex(Handle). , .
, , .
:
CreateMutex (p1,p2,p3);
OpenMutex ();
CreateMutex , , , , . , p2 false, , .
CreateMutex, .
, OpenMutex (po1, po2, po3);
po1 ;
po2 ;
po3 .
po1 :
1) ;
2) . , , , ReleaseMutex, .
po2 , .
, OpenMutex , .
|
|
.
. , . , , , .
Windows, Events. :
1) ;
2) .
, ResetEvent (), ResetEvent, . , , WaitForSingleObject, .
CreateEvent, - pe1, pe2, pe3, pe4.
pe1 ;
pe2 ;
pe3 ;
pe4 .
, NULL. pe2 == true, , . pe3==true, , . pe4 , , . .
, CreateEvent Handle, NULL . pe4 , CreateEvent , GetLastError ERROR_ALREADY_EXISTS.
SetEvent (Handle). , .
ResetEvent (Handle) . .
, PulseEvent (Handle). , , Handle, , . , . , , .
CreateEvent OpenEvent. CreateEvent, , . , CreateEvent, , . OpenEvent , , . :
OpenEvent (po1, po2, po3);
po1 ;;
po2 ;
po3 .
.
po1 , .
a . b . , SetEvent ResetEvent . c . .
.
Windows Semaphore. , , , . , . , , , FIFO. - , ( ). .
|
|
CreateSemaphore (ps1, ps2, ps3, ps4).
ps1 ;
ps2 , , , ps3.
ps4 , . .
Handle , . , , GetLastError ERROR_ALREADY_EXISTS.
. ReleaseSemaphore(Handle, pr2, pr3).
Handle ;
pr2 , ;
pr3 .
, , .
pr2 ps3, ReleaseSemaphore , .
CreateSemaphore (ps1, ps2, ps3, ps4), OpenSemaphore(po1, po2, po3).
CreateSemaphore, , , , , , .
OpenSemaphore , , . OpenEvent.
, , . - , . , . . , .
, - , . , , , , , - , - .
, , , , . , , , . - .