Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pthread_mutex_lock(3T)

pthread_mutex_trylock(3T)

pthread_mutex_unlock(3T)

pthread_mutexattr_init(3T)

pthread_mutexattr_setpshared(3T)



pthread_mutex_init(3T)         DG/UX R4.11MU05        pthread_mutex_init(3T)


NAME
       pthread_mutex_init, pthread_mutex_destroy - initialize or destroy a
       mutex

SYNOPSIS
       int pthread_mutex_init(pthread_mutex_t *mutex,
                              pthread_mutexattr_t *attr);

       int pthread_mutex_destroy(pthread_mutex_t *mutex);

   where:
       mutex  A pointer to a mutex
       attr   A pointer to a mutex attributes object, or NULL

DESCRIPTION
       The pthread_mutex_init() function initializes the mutex pointed to by
       mutex with attributes specified by attr.  If attr is NULL the default
       mutex attributes are used; the effect is the same as passing the
       address of a newly initialized mutex attributes object.

       If the pthread_mutex_init() function fails, the mutex is not
       initialized and the contents of the mutex are undefined.

       The pthread_mutex_destroy() function destroys the mutex pointed to by
       mutex.  Destroying a locked mutex results in undefined behavior.
       Destroying a mutex upon which other threads are currently blocked or
       upon which other threads have yet to execute operations results in
       undefined behavior.

DIAGNOSTICS
   Returns
       If successful, each function returns 0.  Otherwise it returns -1 and
       sets errno to indicate the error.

   Errors
       For each of the following conditions, pthread_mutex_init() returns -1
       and sets errno to the corresponding value:

       [EAGAIN]  The system lacked the necessary resources to initialize
                 another mutex.  In DG/UX, this occurs when trying to
                 initialize a process-shared mutex, and the system-imposed
                 limit on the number of global synchronization queues (for
                 process-shared mutexes and condition variables) has been
                 exceeded.

       [ENOMEM]  Insufficient memory exists to initialize the mutex.  In
                 DG/UX, this occurs when trying to allocate more global
                 synchronization queues in order to initialize a process-
                 shared mutex.

       For each of the following conditions, pthread_mutex_destroy() returns
       -1 and sets errno to the corresponding value:

       [EBUSY]   The system has detected an attempt to destroy a mutex while
                 it is locked or referenced (for example, while being used
                 in a pthread_cond_wait() or pthread_cond_timedwait() by
                 another thread).

       [EINVAL]  The value specified by mutex is invalid.  This occurs when
                 DG/UX has detected that mutex does not point to a properly
                 initialized mutex.

SEE ALSO
       pthread_mutex_lock(3T), pthread_mutex_trylock(3T),
       pthread_mutex_unlock(3T), pthread_mutexattr_init(3T),
       pthread_mutexattr_setpshared(3T).

NOTES
       The kernel configuration variable MAXGLOBALSQS can be used to change
       the system-imposed limit on the number of global synchronization
       queues used for process-shared mutexes and condition variables.

       If a mutex is initialized as process-shared, the underlying global
       synchronization queues are not automatically cleaned up if the
       process terminates or the shared memory area holding the mutex is
       deallocated.  They can only be released by calls to
       pthread_mutex_destroy() on the mutex.  An application that uses
       process-shared mutexes should ensure that it properly destroys all
       process-shared mutexes in order to avoid a leak of global
       synchronization queues.

       DG/UX does not currently allocate any extra memory in order to
       initialize mutexes that are not process-shared.


Licensed material--property of copyright holder(s)

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