The Open Group Base Specifications Issue 8
IEEE Std 1003.1-2024
Copyright © 2001-2024 The IEEE and The Open Group

NAME

cnd_destroy, cnd_init — destroy and initialize condition variables

SYNOPSIS

#include <threads.h>

void cnd_destroy(cnd_t *
cond);
int cnd_init(cnd_t *
cond);

DESCRIPTION

[CX] [Option Start] The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2024 defers to the ISO C standard. [Option End]

The cnd_destroy() function shall release all resources used by the condition variable pointed to by cond. It shall be safe to destroy an initialized condition variable upon which no threads are currently blocked. Attempting to destroy a condition variable upon which other threads are currently blocked results in undefined behavior. A destroyed condition variable object can be reinitialized using cnd_init(); the results of otherwise referencing the object after it has been destroyed are undefined. The behavior is undefined if the value specified by the cond argument to cnd_destroy() does not refer to an initialized condition variable.

The cnd_init() function shall initialize a condition variable. If it succeeds it shall set the variable pointed to by cond to a value that uniquely identifies the newly initialized condition variable. Attempting to initialize an already initialized condition variable results in undefined behavior. A thread that calls cnd_wait() on a newly initialized condition variable shall block.

[CX] [Option Start] See 2.9.9 Synchronization Object Copies and Alternative Mappings for further requirements.

These functions shall not be affected if the calling thread executes a signal handler during the call. [Option End]

RETURN VALUE

The cnd_destroy() function shall not return a value.

The cnd_init() function shall return thrd_success on success, or thrd_nomem if no memory could be allocated for the newly created condition variable, or thrd_error if the request could not be honored.

ERRORS

See RETURN VALUE.


The following sections are informative.

EXAMPLES

None.

APPLICATION USAGE

None.

RATIONALE

These functions are not affected by signal handlers for the reasons stated in XRAT B.2.3 Error Numbers .

FUTURE DIRECTIONS

None.

SEE ALSO

cnd_broadcast , cnd_timedwait

XBD <threads.h>

CHANGE HISTORY

First released in Issue 8. Included for alignment with the ISO/IEC 9899:2018 standard.

End of informative text.

 

return to top of page

UNIX® is a registered Trademark of The Open Group.
POSIX™ is a Trademark of The IEEE.
Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved
[ Main Index | XBD | XSH | XCU | XRAT ]