---
name: "cv_wmesg"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/cv_wmesg"
---

# cv\_wmesg(9)

kernel condition variable

## NAME

**condvar**, **cv\_init**, **cv\_destroy**, **cv\_wait**, **cv\_wait\_sig**, **cv\_timedwait**, **cv\_timedwait\_sig**, **cv\_signal**, **cv\_broadcast**, **cv\_broadcastpri**, **cv\_wmesg** – kernel condition variable

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/proc.h\>**

**#include \<sys/condvar.h\>**

*void*\

**cv\_init**(*struct cv \*cvp*, *const char \*desc*);

*void*\

**cv\_destroy**(*struct cv \*cvp*);

*void*\

**cv\_wait**(*struct cv \*cvp*, *struct mtx \*mp*);

*int*\

**cv\_wait\_sig**(*struct cv \*cvp*, *struct mtx \*mp*);

*int*\

**cv\_timedwait**(*struct cv \*cvp*, *struct mtx \*mp*, *int timo*);

*int*\

**cv\_timedwait\_sig**(*struct cv \*cvp*, *struct mtx \*mp*, *int timo*);

*void*\

**cv\_signal**(*struct cv \*cvp*);

*void*\

**cv\_broadcast**(*struct cv \*cvp*);

*void*\

**cv\_broadcastpri**(*struct cv \*cvp*, *int pri*);

*const* *char* *\**\

**cv\_wmesg**(*struct cv \*cvp*);

## DESCRIPTION

Condition variables are used in conjunction with mutexes to wait for conditions to occur. Condition variables are created with **cv\_init**(), where *cvp* is a pointer to space for a *struct* *cv*, and *desc* is a pointer to a null-terminated character string that describes the condition variable. Condition variables are destroyed with **cv\_destroy**(). Threads wait on condition variables by calling **cv\_wait**(), **cv\_wait\_sig**(), **cv\_timedwait**(), or **cv\_timedwait\_sig**(). Threads unblock waiters by calling **cv\_signal**() to unblock one waiter, or **cv\_broadcast**() or **cv\_broadcastpri**() to unblock all waiters. In addition to waking waiters, **cv\_broadcastpri**() ensures that all of the waiters have a priority of at least *pri* by raising the priority of any threads that do not. **cv\_wmesg**() returns the description string of *cvp*, as set by the initial call to **cv\_init**().

A thread must hold *mp* before calling **cv\_wait**(), **cv\_wait\_sig**(), **cv\_timedwait**(), or **cv\_timedwait\_sig**(). When a thread waits on a condition, *mp* is atomically released before the thread is blocked, then atomically reacquired before the function call returns. All waiters must pass the same *mp* in conjunction with *cvp*.

When **cv\_wait**(), **cv\_wait\_sig**(), **cv\_timedwait**(), and **cv\_timedwait\_sig**() unblock, their calling threads are made runnable. **cv\_timedwait**() and **cv\_timedwait\_sig**() wait for at most *timo* / HZ seconds before being unblocked and returning EWOULDBLOCK; otherwise, they return 0. **cv\_wait\_sig**() and **cv\_timedwait\_sig**() return prematurely with a value of EINTR or ERESTART if a signal is caught, or 0 if signaled via **cv\_signal**() or **cv\_broadcast**().

## RETURN VALUES

If successful, **cv\_wait\_sig**(), **cv\_timedwait**(), and **cv\_timedwait\_sig**() return 0. Otherwise, a non-zero error code is returned.

**cv\_wmesg**() returns the description string that was passed to **cv\_init**().

## ERRORS

**cv\_wait\_sig**() and **cv\_timedwait\_sig**() will fail if:

- \[EINTR\]

  An unmasked signal was caught.

- \[ERESTART\]

  A masked signal was caught.

**cv\_timedwait**() and **cv\_timedwait\_sig**() will fail if:

- \[EWOULDBLOCK\]

  Timeout expired.

## SEE ALSO

[msleep(9)](/msleep/9.md), [mtx\_pool(9)](/mtx_pool/9.md), [mutex(9)](/mutex/9.md), [sema(9)](/sema/9.md), [sx(9)](/sx/9.md)
