43.9 Interface Comparison Tables

The synchronization functions manipulate mutexes, reader-writer locks, semaphores, and condition variables. The following sections group the functions by these tasks, briefly describe them, and list the NKS, pthread, and UI equivalent functions.

43.9.1 Mutex Interface Comparison

The following functions manage mutexes:

NKS Function

NKS Description

Pthread Equivalent

UI Equivalent

NXLock

Locks the specified mutex

pthread_mutex_lock

mutex_lock

NX_LOCK_INFO_ALLOC

Declares and initializes a variable of type NXLockInfo_t

 

NXMutexAlloc

Allocates and initializes a mutex

 

NXMutexDeinit

Deinitializes the specified mutex

pthread_mutex_destroy

mutex_destroy

NXMutexFree

Deallocates the specified mutex

 

NXMutexInit

Initializes a mutex

pthread_mutex_init

mutex_init

NXMutexIsOwned

Checks to see if the thread owns the specified mutex

 

NXTryLock

Makes a single attempt to acquire the specified mutex

pthread_mutex_trylock

mutex_trylock

NXUnlock

Unlocks the specified mutex

pthread_mutex_unlock

mutex_unlock

When NDEBUG is not defined, the following functions help you debug recursive mutexes. These are only available for NKS mutexes:

NKS Function

NKS Description

NXMutexDepth

Determines the depth of a recursive mutex.

NXMutexTestFlag

Determines whether the mutex is a recursive mutex.

43.9.2 Reader-Writer Lock Interface Comparison

The following functions manage reader-writer locks.

NKS Function

NKS Description

PThread Equivalent

UI Equivalent

NXRdLock

Locks the specified reader-writer lock in the read mode

pthread_rwlock_rdlock

rw_rdlock

NXRwLockAlloc

Allocates and initializes a reader-writer lock

 

NXRwLockDeinit

Deinitializes the specified reader-writer lock

pthread_rwlock_destroy

rwlock_destroy

NXRwLockFree

Frees the specified reader-writer lock

 

NXRwLockInit

Initializes a reader-writer lock

pthread_rwlock_init

rwlock_init

NXRwLockIsOwned

Checks to see if the thread owns the specified reader-writer lock

 

NXTryRdLock

Makes a single attempt to acquire the specified reader-writer lock in the read mode

pthread_rwlock_tryrdlock

rw_tryrdlock

NXTryWrLock

Makes a single attempt to acquire the specified reader-writer lock in the write mode

pthread_rwlock_trywrlock

rw_trywrlock

NXWrLock

Locks the specified reader-writer lock in the write mode

pthread_rwlock_wrlock

rw_wrlock

NXRwUnlock

Unlocks the specified reader-writer lock

pthread_rwlock_unlock

rw_unlock

NXRwLockUpgrade

Converts the specified reader-writer lock from read mode to write mode.

 

 

43.9.3 Semaphore Interface Comparison

The following functions manage semaphores:

NKS Function

NKS Description

POSIX Equivalent

UI Equivalent

NXSemaAlloc

Allocates and initializes a semaphore

NXSemaDeinit

Deinitializes the specified semaphore

sem_destroy

sema_destroy

NXSemaFree

Frees the specified semaphore

NXSemaInit

Initializes a semaphore

sem_init

sema_init

NXSemaPost

Releases the resource protected by the specified semaphore

sem_post

sema_post

NXSemaTryWait

Makes a single attempt to acquire the resource protected by a semaphore

sem_trywait

sema_trywait

NXSemaWait

Acquires the resource protected by a semaphore

sem_wait

sema_wait

For System-V semaphores, which create shareable semaphores, see System-V Semaphore Functions

43.9.4 Condition Variable Interface Comparison

The following functions manage condition variables:

NKS Function

NKS Description

Pthread Equivalent

UI Equivalent

NXCondAlloc

Allocates and initializes a condition variable

 

 

NXCondBroadcast

Wakes up all the threads blocked on the condition variable

pthread_cond_broadcast

cond_broadcast

NXCondDeinit

Deinitializes the condition variable

pthread_cond_destroy

cond_destroy

NXCondFree

Deallocates the condition variable

 

NXCondInit

Initializes a specified condition variable

pthread_cond_init

cond_init

NXCondSignal

Signals on the condition variable

pthread_cond_signal

cond_signal

NXCondTimedWait

Waits on the condition variable for a limited time

pthread_cond_timedwait

cond_timedwait

NXCondWait

Waits on the condition variable

pthread_cond_wait

cond_wait