实现linux下的各种锁

http://www.ibm.com/developerworks%20/library/l-ipc2lin2.html

 

 

Table 1. Synchronization mapping

Windows Linux -- threads Linux -- process
Mutex Mutex - pthread library System V semaphores
Critical section Mutex - pthread library Not applicable as critical sections are used only between the threads of the same process
Semaphore Conditional Variable with mutex - pthreads
POSIX semaphores
System V Semaphores
Event Conditional Variable with mutex - pthreads System V Semaphores

 

Table 2. Semaphore mapping

Windows Linux Threads Linux Process Classification
CreateSemaphore sem_init semget
semctl
Context specific
OpenSemaphore Not applicable semget Context specific
WaitForSingleObject sem_wait
sem_trywait
semop Context specific
ReleaseSemaphore sem_post semop Context specific
CloseHandle sem_destroy semctl Context specific

你可能感兴趣的:(实现linux下的各种锁)