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 - pthreadsPOSIX 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 | semgetsemctl | Context specific |
OpenSemaphore | Not applicable | semget | Context specific |
WaitForSingleObject | sem_waitsem_trywait | semop | Context specific |
ReleaseSemaphore | sem_post | semop | Context specific |
CloseHandle | sem_destroy | semctl | Context specific |
本文对比了Windows、Linux线程及Linux进程间的同步机制,包括互斥锁、临界区、信号量和事件等,并详细列举了这些同步机制在不同环境下的映射关系。
1277

被折叠的 条评论
为什么被折叠?



