pthread_mutexattr_getkind_np Subroutine

Purpose

Returns the value of the kind attribute of a mutex attributes object.

Library

Threads Library (libpthreads.a)

Syntax

#include <pthread.h>
int pthread_mutexattr_getkind_np ( attr,  kind)
pthread_mutexattr_t *attr;
int *kind;

Description

The pthread_mutexattr_getkind_np subroutine returns the value of the kind attribute of the mutex attributes object attr. This attribute specifies the kind of the mutex that is created with this attribute object. It can have one of the following values:

Table 1. Mutex Attribute Values
Item Description
MUTEX_FAST_NP Denotes a fast mutex. A fast mutex can be locked only once. If the same thread unlocks twice the same fast mutex, the thread will deadlock. Any thread can unlock a fast mutex. A fast mutex is not compatible with the priority inheritance protocol.
MUTEX_RECURSIVE_NP Denotes a recursive mutex. A recursive mutex can be locked more than once by the same thread without causing that thread to deadlock. The thread must then unlock the mutex as many times as it locked it. Only the thread that locked a recursive mutex can unlock it. A recursive mutex must not be used with condition variables.
MUTEX_NONRECURSIVE_NP Denotes the default non-recursive POSIX compliant mutex.
Note:
  1. The pthread.h header file must be the first included file of each source file by using the threads library. Otherwise, the -D_THREAD_SAFE compilation flag should be used, or the cc_r compiler used. In this case, the flag is automatically set.
  2. The pthread_mutexattr_getkind_np subroutine is not portable.

This subroutine is not POSIX compliant and is provided only for compatibility with DCE threads. It must not be used when writing new applications.

Parameters

Table 2. Parameters
Item Description
attr Specifies the mutex attributes object.
kind Points to where the kind attribute value will be stored.

Return Values

Upon successful completion, the value of the kind attribute is returned via the kind parameter, and 0 is returned. Otherwise, an error code is returned.

Error Codes

The pthread_mutexattr_getkind_np subroutine is unsuccessful if the following is true:

Table 3. Error Codes
Item Description
EINVAL The attr parameter is not valid.