pthread_condattr_getkind_np() — Get kind attribute from a condition variable attribute object

Standards

Standards / Extensions C or C++ Dependencies
z/OS® UNIX both

POSIX(ON)

Format

#define _OPEN_THREADS
#define _OPEN_SYS
#include <pthread.h>

int pthread_condattr_getkind_np(pthread_condattr_t *attr, int *kind);

General description

Gets the attribute kind for the condition variable attribute object attr. Condition variable attribute objects are similar to mutex attribute objects. You can use them to manage the characteristics of condition variables in your application. They define the set of values for the condition variable during its creation.

The valid values for the attribute kind are:
__COND_DEFAULT
No defined attributes.
__COND_NODEBUG
State changes to this condition variable will not be reported to the debug interface, even though it is present.

Returned value

If successful, pthread_condattr_getkind_np() returns 0.

If unsuccessful, pthread_condattr_getkind_np() returns -1 and sets errno to one of the following values:
Error Code
Description
EINVAL
The value specified for attr is not valid.

Example

CELEBP24
⁄* CELEBP24 *⁄
#pragma runopts(TEST(ALL))

#ifndef _OPEN_THREADS
#define _OPEN_THREADS
#define _OPEN_SYS          ⁄* Needed to identify __COND_NODEBUG and
                              __COND_DEFAULT *⁄
#endif

#include <stdio.h>
#include <pthread.h>

pthread_condattr_t attr;

int kind;

main() {
    if (pthread_condattr_init(&attr) == -1) {
       perror("pthread_condattr_init()");
       exit(1);
    }

    if (pthread_condattr_setkind_np(&attr, __COND_NODEBUG) == -1) {
       perror("pthread_condattr_setkind_np()");
       exit(1);
    }

    if (pthread_condattr_getkind_np(&attr, &kind) == -1) {
    exit(1);
    }

    switch(kind) {

      case __COND_DEFAULT:
        printf("\ncondition variable will have no defined attributes");
        break;

      case __COND_NODEBUG:
        printf("\ncondition variable will have nodebug attribute");
        break;

      default:
        printf("\nattribute kind value returned by \
pthread_condattr_getkind_no() unrecognized");

    }

   exit(0);
}

Related information