pthread_condattr_setkind_np() — Set 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_setkind_np(pthread_condattr_t *attr, int kind);
General description
Sets 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 to be used 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_setkind_np() returns 0.
If unsuccessful, pthread_condattr_setkind_np() returns
-1 and sets errno to one of the following values:
- Error Code
- Description
- EINVAL
- The value specified for attr or kind is not valid.
Example
CELEBP26
/* CELEBP26 */
#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);
}