*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: cond_init | Section: 9 | Source: OpenBSD | File: cond_init.9
COND_INIT(9) FreeBSD Kernel Developer's Manual COND_INIT(9) NAME cond_init, cond_wait, cond_signal, COND_INITIALIZER - wait condition API SYNOPSIS #include <sys/systm.h> void cond_init(struct cond *c); void cond_wait(struct cond *c, const char *wmesg); void cond_signal(struct cond *c); COND_INITIALIZER(); DESCRIPTION The wait condition API allows a thread to sleep while it waits for a notification, aka signal, that pending work has completed. cond_init() initialises the wait condition c for use. cond_wait() is used to sleep on the wait condition c until whatever the thread is waiting on calls cond_signal(). wmesg is a pointer to a character string indicating the reason the thread is sleeping. cond_signal() is used to notify the thread waiting on c that the work has finished and it may proceed. COND_INITIALIZER() initialises a declaration of a cond for use. CONTEXT cond_init(), and cond_signal() can be called during autoconf, from process context, or from interrupt context. cond_wait() can be called from process context. EXAMPLES taskq_barrier(9) is implemented using the wait condition API. The following is a commented copy of the implementation: static void taskq_barrier_task(void *); void taskq_barrier(struct taskq *tq) { struct cond c; struct task t; /* * any currently running work has to have finished * before this new task can be run. */ cond_init(&c); task_init(&t, taskq_barrier_task, &c); task_add(tq, &t); /* wait until the task runs and signals completion */ cond_wait(&c, "tqbar"); } static void taskq_barrier_task(void *p) { struct cond *c = p; /* * all previous tasks have run, signal the thread waiting * in taskq_barrier */ cond_signal(c); } FreeBSD 14.1-RELEASE-p8 March 11, 2022 FreeBSD 14.1-RELEASE-p8

Navigation Options