---
name: "pthread_cond_clockwait"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pthread_cond_clockwait"
---

# pthread\_cond\_clockwait(3)

wait on a condition variable for a specific amount of time

## NAME

**pthread\_cond\_timedwait** – wait on a condition variable for a specific amount of time

## LIBRARY

POSIX Threads Library (libpthread, -lpthread)

## SYNOPSIS

**#include \<pthread.h\>**

*int*\

**pthread\_cond\_timedwait**(*pthread\_cond\_t \*cond*, *pthread\_mutex\_t \*mutex*, *const struct timespec \*abstime*);

**#include \<time.h\>**

*int*\

**pthread\_cond\_clockwait**(*pthread\_cond\_t \*cond*, *pthread\_mutex\_t \*mutex*, *clockid\_t clockid*, *const struct timespec \*abstime*);

## DESCRIPTION

The **pthread\_cond\_timedwait**() and **pthread\_cond\_clockwait**() functions atomically blocks the current thread waiting on the condition variable specified by *cond*, and releases the mutex specified by *mutex*. The waiting thread unblocks only after another thread calls [pthread\_cond\_signal(3)](/pthread_cond_signal/3.md), or [pthread\_cond\_broadcast(3)](/pthread_cond_broadcast/3.md) with the same condition variable, or if the system time reaches the time specified in *abstime*, and the current thread reacquires the lock on *mutex*.

The **pthread\_cond\_clockwait**() function is identical to **pthread\_cond\_timedwait**(), except in the way the clock to measure time-out is named. For the **pthread\_cond\_timedwait**() function, the clock used to measure *abstime* can be specified during creation of the condition variable using [pthread\_condattr\_setclock(3)](/pthread_condattr_setclock/3.md). For the **pthread\_cond\_clockwait**() function, the clock is specified by the *clockid* argument.

## RETURN VALUES

If successful, the **pthread\_cond\_timedwait**() function will return zero. Otherwise an error number will be returned to indicate the error.

## ERRORS

The **pthread\_cond\_timedwait**() function will fail if:

- \[EINVAL\]

  The value specified by *cond*, *mutex* or *abstime* is invalid.

- \[ETIMEDOUT\]

  The system time has reached or exceeded the time specified in *abstime*.

- \[EPERM\]

  The specified *mutex* was not locked by the calling thread.

## SEE ALSO

[pthread\_cond\_broadcast(3)](/pthread_cond_broadcast/3.md), [pthread\_cond\_destroy(3)](/pthread_cond_destroy/3.md), [pthread\_cond\_init(3)](/pthread_cond_init/3.md), [pthread\_cond\_signal(3)](/pthread_cond_signal/3.md), [pthread\_cond\_wait(3)](/pthread_cond_wait/3.md), [pthread\_condattr\_setclock(3)](/pthread_condattr_setclock/3.md)

## STANDARDS

The **pthread\_cond\_timedwait**() function conforms to ISO/IEC 9945-1:1996 (“POSIX.1”). The **pthread\_cond\_clockwait**() function conforms to IEEE Std 1003.1-2024 (“POSIX.1”) and appeared in FreeBSD 16.0.
