프로그래밍/C
뮤텍스
우끼우끼몽키
2016. 9. 15. 19:53
설명 |
윈도우 함수명 |
리눅스개열 함수명 |
생성 |
CreateMutex |
pthread_mutex_init |
제거 |
CloseHandle |
pthread_mutex_destory |
잠금 |
WaitForSingleObject(hMutex, INFINITE); |
pthread_mutex_lock |
잠금시도 |
WaitForSingleObject(hMutex, 0); |
pthread_mutex_trylock |
해제 |
ReleaseMutex |
pthread_mutex_unlock |
윈도우 함수를 기준으로 사용법은..
1. HANDLE hMutex = CreateMutex( NULL, FALSE, NULL );
2. WaitForSingleObject(hMutex, INFINITE);
3. 동기화에 필요한 행동
4. ReleaseMutex( hMutex );
5. 종료할 때 CloseHandle( hMutex );