[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

pthread_mutexattr_setkind_np Subroutine


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


Threads Library (libpthreads.a)


#include <pthread.h>

int pthread_mutexattr_setkind_np ( attr, kind)
pthread_mutexattr_t *attr;
int kind;


The pthread_mutexattr_setkind_np subroutine sets the value of the kind attribute of the mutex attributes object attr. This attribute specifies the kind of the mutex created with this attributes object.

  1. The pthread.h header file must be the first included file of each source file 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_setkind_np subroutine is not portable.

This subroutine is provided only for compatibility with the DCE threads. It should not be used when writing new applications.


attr Specifies the mutex attributes object.
kind Specifies the kind to set. It must have one of the following values:
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.
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.
Denotes the default non-recursive POSIX compliant mutex.

Return Values

Upon successful completion, 0 is returned. Otherwise, an error code is returned.

Error Codes

The pthread_mutexattr_setkind_np subroutine is unsuccessful if the following is true:

EINVAL The attr parameter is not valid.
ENOTSUP The value of the kind parameter is not supported.

Related Information

The pthread_mutexattr_getkind_np (pthread_mutexattr_getkind_np Subroutine) subroutine.

Using Mutexes in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]