CND(3) Library Functions Manual CND(3)

cndcondition 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 () 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 () function destroys the cond condition variable.

The () function initializes a new cond variable.

The () 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 () 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 () 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.

pthread_cond(3), threads(3)

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