pthread_mutex_init

Initializes a mutex.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

  #include <pthread.h>
   
  int   pthread_mutex_init  (
     pthread_mutex_t             *mutex,
     const pthread_mutexattr_t   *attr);
  

Parameters

mutex

(IN) Points to the mutex to be initialized.

attr

(IN) Points to the special attributes for the mutex and determines whether a mutex can be used recursively. By default, a mutex is recursive and private. NetWare does not support shared mutexes.

Return Values

If successful, returns zero; otherwise, returns a nonzero error code:

Decimal

Constant

Description

5

ENOMEM

Insufficient memory to complete this call

Remarks

To help avoid deadlock, you should impose strict ordering among all locks in the application that a thread can be hold at the same time. Hierarchy violations are checked only if the application is built with the compilation options, DEBUG and _LOCKTEST.

Pthread mutexes are not tracked by the operating system and cannot be displayed by the NetWare internal debugger. They do not need to be destroyed. If they are, the destroy function merely validates that the mutex isn't currently in use. If you plan to use the NetWare debugger to clean up and evaluate your mutex implementation, you need to use the NKS mutex functions.

See Also