Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pthread_mutex_init(3P)

pthread_mutex_destroy(3P)

pthread_mutex_trylock(3P)

pthread_mutex_unlock(3P)

PTHREAD_MUTEX_LOCK(3P)               SysV               PTHREAD_MUTEX_LOCK(3P)



NAME
     pthread_mutex_lock - Locks a mutex

SYNOPSIS
     #include <pthread.h>

     int pthread_mutex_lock (mutex)
     pthread_mutex_t *mutex;

DESCRIPTION
     The pthread_mutex_lock function locks the specified mutex and makes the
     calling thread the owner of the mutex.  If mutex is already locked, the
     pthread_mutex_lock function blocks the calling thread until the mutex is
     available.

     The mutex argument specifies the ID of the mutex to be locked.

     Because the pthread_mutex_lock function is not a cancellation point, you
     can safely call the pthread_mutex_lock function during a cleanup routine.
     During cleanup, it is often necessary to lock a mutex so that  you can
     change the state that says that a resource is owned.  However, care must
     be taken to ensure that the thread does not already have the mutex
     locked.

NOTES
     This interface is based on draft 4 of the IEEE P1003.4a standard, and
     will be changed to conform to the final version.

DIAGNOSTICS
     Upon successful completion, a value of 0 (zero) is returned. Otherwise,
     no mutex is created, -1 is returned, and errno is set to indicate the
     error.

ERRORS
     If the pthread_mutex_lock function fails, errno may be set to one of the
     following values:

     [EINVAL]  The value specified by the mutex argument is invalid.

     [EDEADLK] The mutex was already locked by the calling thread.

SEE ALSO
     pthread_mutex_init(3P), pthread_mutex_destroy(3P),
     pthread_mutex_trylock(3P), pthread_mutex_unlock(3P)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026