pthread_mutex_trylock

Makes a single attempt to acquire the specified mutex.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

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

Parameters

mutex

(IN) Points to the mutex to acquire.

Return Values

If successful in acquiring the mutex, returns 0. Otherwise, returns a nonzero error code.

Decimal

Constant

Description

9

EINVAL

The mutex parameter is not a valid mutex.

62

EBUSY

The mutex is not currently available.

Remarks

Because this is a conditional acquisition, the hierarchy constraint for locks is relaxed for this acquisition. If the lock being acquired is not available (is held by a different thread), pthread_mutex_trylock makes no further attempt and returns EBUSY.

See Also