首页 > 代码库 > Windows 和 Linux 的IPC API对应表

Windows 和 Linux 的IPC API对应表

原文出处:http://blog.csdn.net/zhengdy/article/details/5485472

 

                                             Windows 和 Linux 的IPC API对应表

 

Table 1. Process mapping
WindowsLinuxClassification
CreateProcess()
CreateProcessAsUser()
fork()
setuid()
exec()
Mappable
TerminateProcess()kill()Mappable
SetThreadpriority()
GetThreadPriority()
Setpriority()
GetPriority()
Mappable
GetCurrentProcessID()getpid()Mappable
Exitprocess()exit()Mappable
WaitForSingleObjec()
WaitForMultipleObject()
GetExitCodeProcess()
waitpid()
※Using Sys V semaphores, WaitForSingleObjec/MultipleObject
can be implemented
Context specific
GetEnvironmentVariable()
SetEnvironmentVariable()
getenv()
setenv()
Mappable

 

 

Table 2. Thread mapping
WindowsLinuxClassification
CreateThread()pthread_create
pthread_attr_init
pthread_attr_setstacksize
pthread_attr_destroy
Mappable
ThreadExit()pthread_exitMappable
WaitForSingleObject()pthread_join
pthread_attr_setdetachstate
pthread_detach
Mappable
SetPriorityClass()
SetThreadPriority()
setpriority
sched_setscheduler
sched_setparam

pthread_setschedparam
pthread_setschedpolicy
pthread_attr_setschedparam
pthread_attr_setschedpolicy>

Context Specific

 

 

Table 3. Synchronization mapping
WindowsLinux -- threadsLinux -- process
MutexMutex - pthread librarySystem V semaphores
Critical sectionMutex - pthread libraryNot applicable as critical sections are used only between the threads of the same process
SemaphoreConditional Variable with mutex - pthreads
POSIX semaphores
System V Semaphores
EventConditional Variable with mutex - pthreadsSystem V Semaphores

 

 

Table 4. Semaphore mapping
WindowsLinux -- threadsLinux -- processClassification
CreateSemaphoresem_initsemget
semctl
Context specific
OpenSemaphoreNot applicablesemgetContext specific
WaitForSingleObjectsem_wait
sem_trywait
semopContext specific
ReleaseSemaphoresem_postsemopContext specific
CloseHandlesem_destroysemctlContext specific

 

 

Table 5. Event objects mapping
WindowsLinux -- threadsLinux -- processClassification
CreateEvent
OpenEvent
pthread_cond_init
sem_init
semget
semctl
Context specific
SetEventpthread_cond_signal
sem_post
semopContext specific
ResetEventN/AN/AContext specific
WaitForSingleObjectpthread_cond_wait
pthread_cond_timedwait
sem_wait
sem_trywait
semopContext specific
CloseHandlepthread_cond_destroy
sem_destroy
semctlContext specific

 

 

Table 6. Mutex mapping
WindowsLinux -- threadsLinux -- processClassification
CreateMutexpthreads_mutex_initsemget
semctl
Context specific
OpenMutexNot applicablesemgetContext specific
WaitForSingleObjectpthread_mutex_lock
pthread_mutex_trylock
semopContext specific
ReleaseMutexpthread_mutex_unlocksemopContext specific
CloseHandlepthread_mutex_destroysemctlContext specific

 

 

Table 7. Critical section mapping
WindowsLinuxClassification
InitializeCriticalSection
InitializeCriticalSectionAndSpinCount
pthreads_mutex_initMappable
EnterCriticalSection
TryEnterCriticalSection
pthread_mutex_lock
pthread_mutex_trylock
Mappable
LeaveCriticalSectionpthread_mutex_unlockMappable
DeleteCriticalSectionpthread_mutex_destroyMappable

 

 

Table 6. Mutex mapping
WindowsLinux -- threadsLinux -- processClassification
SignalObjectAndWaitsemopsemopContext specific
WaitForMultipleObjectssem_wait
sem_trywait
semopContext specific

Windows 和 Linux 的IPC API对应表