pthread_mutex_lock

Locks the specified mutex.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

  #include <pthread.h>
   
  int   pthread_mutex_lock (
     pthread_mutex_t   *mutex);
  

Parameters

mutex

(IN) Points to the mutex to lock. It is expected that the hierarchy value of this mutex is greater than any of the mutexes that might be currently held by this thread. (For a discussion on lock hierarchy, see pthread_mutex_init.)

Return Values

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

Decimal

Constant

Description

5

ENOMEM

Insufficient memory to complete this call

9

EINVAL

The mutex is not a valid mutex.

Remarks

The thread_mutex_lock function acquires the specified mutually exclusive lock. If the lock being acquired is not free (is held by a different thread), the calling thread waits until the lock can be acquired. No assumptions can be made about the way the calling thread might wait for the lock to become free. The mutex is not guaranteed to be FIFO.

See Also