---
name: "thr_wake"
section: "2"
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/thr_wake"
---

# thr\_wake(2)

wake up the suspended thread

## NAME

**thr\_wake** – wake up the suspended thread

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*int*\

**thr\_wake**(*long id*);

## DESCRIPTION

This function is intended for implementing threading. Normal applications should use [pthread\_cond\_timedwait(3)](/pthread_cond_timedwait/3.md) together with [pthread\_cond\_broadcast(3)](/pthread_cond_broadcast/3.md) for typical safe suspension with cooperation of the thread being suspended, or [pthread\_suspend\_np(3)](/pthread_suspend_np/3.md) and [pthread\_resume\_np(3)](/pthread_resume_np/3.md) in some specific situations, instead.

Passing the thread identifier of the calling thread( see [thr\_self(2)](/thr_self/2.md)) to **thr\_wake**() sets a thread's flag to cause the next signal-interruptible sleep of that thread in the kernel to fail immediately with the EINTR error. The flag is cleared by an interruptible sleep attempt or by a call to [thr\_suspend(2)](/thr_suspend/2.md). This is used by the system threading library to implement cancellation.

If *id* is not equal to the current thread identifier, the specified thread is woken up if suspended by the [thr\_suspend(2)](/thr_suspend/2.md) system call. If the thread is not suspended at the time of the **thr\_wake** call, the wake is remembered and the next attempt of the thread to suspend itself with the [thr\_suspend(2)](/thr_suspend/2.md) results in immediate return with success. Only one wake is remembered.

## RETURN VALUES

The **thr\_wake()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

The **thr\_wake**() operation returns these errors:

- \[ESRCH\]

  The specified thread was not found or does not belong to the process of the calling thread.

## SEE ALSO

[ps(1)](/ps/1.md), [thr\_self(2)](/thr_self/2.md), [thr\_suspend(2)](/thr_suspend/2.md), [pthread\_cancel(3)](/pthread_cancel/3.md), [pthread\_resume\_np(3)](/pthread_resume_np/3.md), [pthread\_suspend\_np(3)](/pthread_suspend_np/3.md)

## STANDARDS

The **thr\_suspend**() system call is non-standard and is used by library “libthr” to implement IEEE Std 1003.1-2001 (“POSIX.1”) [pthread(3)](/pthread/3.md) functionality.

## HISTORY

The **thr\_suspend**() system call first appeared in FreeBSD 5.2.
