| CND(3) | Library Functions Manual | CND(3) |
cnd — condition
variable functions
POSIX Threads Library (libpthread, -lpthread)
#include
<threads.h>
int
cnd_broadcast(cnd_t
*cond);
void
cnd_destroy(cnd_t
*cond);
int
cnd_init(cnd_t
*cond);
int
cnd_signal(cnd_t
*cond);
int
cnd_timedwait(cnd_t * restrict
cond, mtx_t * restrict mtx,
const struct timespec * restrict ts);
int
cnd_wait(cnd_t
*cond, mtx_t
*mtx);
The
cnd_broadcast()
function unblocks all threads that are blocked on a condition variable
cond at the time of the call. If no thread is blocked
on the cond condition variable at the time of the
call, the function does nothing and returns success.
The
cnd_destroy()
function destroys the cond condition variable.
The
cnd_init()
function initializes a new cond variable.
The
cnd_signal()
function unblock one thread that currently waits on the
cond variable. If there are no threads blocked,
cnd_signal() does nothing and returns success.
The
cnd_timedwait()
function atomically unlocks the mutex mtx and blocks
on the condition variable cond until a thread is
signalled by a call to cnd_signal() or
cnd_broadcast() or timeout ts
has been reached. The ts parameter is specified as
TIME_UTC based calendar time. If the mutex is not
locked by the calling thread then behavior is undefined.
The
cnd_wait()
function atomically unlocks the mutex mtx and tries to
block on the conditional variable cond until a thread
is signalled by a call to cnd_signal() or
cnd_broadcast(). The mtx mutex
is locked again before the function returns. If the mutex is not locked by
the calling thread then behavior is undefined.
The cnd_broadcast() function returns
thrd_success on success or
thrd_error on failure.
The cnd_destroy() function returns no
value.
The cnd_init() function returns
thrd_success on success or
thrd_error on failure.
The cnd_signal() function returns
thrd_success on success or
thrd_error on failure.
The cnd_timedwait() function returns
thrd_success on success, otherwise
thrd_timedout to indicate that system time has
reached or exceeded the time specified in ts, or
thrd_error on failure.
The cnd_wait() function returns
thrd_success on success or
thrd_error on failure.
The cnd interface conforms to
ISO/IEC 9899:2011
(“ISO C11”).
This interface first appeared in NetBSD 9.
Kamil Rytarowski <kamil@NetBSD.org>
| October 16, 2016 | NetBSD 11.0 |