[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    pthread_condattr_init(3T) manual page Table of Contents

Name

pthread_condattr_init, pthread_condattr_setpshared, pthread_condattr_getpshared, pthread_condattr_destroy - condition variable initialization attributes

Synopsis

#include <pthread.h>

int pthread_condattr_init(pthread_condattr_t *attr);
int pthread_condattr_setpshared(pthread_condattr_t *attr, int process-shared);
int pthread_condattr_getpshared (const pthread_condattr_t *attr, int *process-shared);
int pthread_condattr_destroy(pthread_condattr_t *attr);

MT-Level

MT-Safe

Description

Initialize

The function pthread_condattr_init() initializes a condition variable attributes object attr with the default value for all the attributes.

At present, the only attribute available is the scope of condition variables, specified by process-shared.

The default value of the process-shared attribute is PTHREAD_PROCESS_PRIVATE , which only allows the condition variable to be operated upon by threads created within the same process as the thread that initialized the condition variable. If threads from other processes try to operate on this condition variable, the behavior is undefined.

The process-shared attribute may be set to PTHREAD_PROCESS_SHARED which allows a condition variable to be operated upon by any thread with access to the memory allocated to the condition variable, even if the condition variable is allocated in memory that is shared by multiple processes.

Attempts to initialize previously initialized condition variable attributes object will leave the storage allocated by the previous initialization unallocated.

Once a condition variable attributes object initializes one or more condition variables, any function affecting the attributes object (including destruction) will not effect any previously initialized condition variables.

Set/Get Scope

pthread_condattr_setpshared() sets the process-shared attribute in an initialized attributes object referenced by attr. pthread_condattr_getpshared() obtains the value of the process-shared attribute from the attributes object referenced by attr.

Destroy

pthread_condattr_destroy() destroys a condition variable attributes object; the object becomes uninitialized. A destroyed condition variable attributes object can be reinitialized with pthread_condattr_init(); however, the results of referencing the object after it has been destroyed are undefined.

Return Values

pthread_condattr_init(), pthread_condattr_destroy(), and pthread_condattr_setpshared() return 0 upon a successful return; otherwise, an error number is returned.

pthread_condattr_getpshared() returns 0 upon a successful return, and stores the value of the process-shared attribute of attr in the object referenced by the process-shared parameter; otherwise, an error number is returned.

Errors

pthread_condattr_init() returns an error number if any of the following conditions are detected:
ENOMEM
Insufficient memory exists to initialize the condition variable attributes object.

pthread_condattr_destroy(), pthread_condattr_getpshared(), and pthread_condattr_setpshared() return an error number if the following condition is detected:

EINVAL
The value specified by attr is invalid.

pthread_condattr_setpshared() returns an error number if the following condition is detected:

EINVAL
The new value specified for the attribute is outside the range of legal values for that attribute.

See Also

cond_init(3T) , pthread_create(3T) , pthread_cond_init(3T) , pthread_mutex_init(3T) .


Table of Contents