thr_suspend(2)

thr_suspend2

Suspend the calling thread

Usage

#include <sys/thr.h>

int

thr_suspend(struct timespec *timeout);

Library

Standard C Library (libc, -lc)

Overview

This function is intended for implementing threading. Normal applications should use pthread_cond_timedwait(3) together with pthread_cond_broadcast(3) for typical safe suspension with cooperation of the thread being suspended, or pthread_suspend_np(3) and pthread_resume_np(3) in some specific situations, instead.

The thr_suspend() system call puts the calling thread in a suspended state, where it is not eligible for CPU time. This state is exited by another thread calling thr_wake(2), when the time interval specified by timeout has elapsed, or by the delivery of a signal to the suspended thread.

If the timeout argument is NULL, the suspended state can be only terminated by explicit thr_wake() or signal.

If a wake from thr_wake(2) was delivered before the thr_suspend call, the thread is not put into a suspended state. Instead, the call returns immediately without an error.

If a thread previously called thr_wake(2) with its own thread identifier, which resulted in setting the internal kernel flag to immediately abort interruptible sleeps with an EINTR error( see thr_wake(2)), the flag is cleared. As with thr_wake(2) called from another thread, the next thr_suspend call does not result in suspension.

Return values

The thr_suspend() 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_suspend() operation returns the following errors:

[EFAULT]

The memory pointed to by the timeout argument is not valid.

[ETIMEDOUT]

The specified timeout expired.

[ETIMEDOUT]

The timeout argument specified a zero time interval.

[EINTR]

The sleep was interrupted by a signal.

Releases

25 releases since FreeBSD 10.4-RELEASE; the text changed 12 times.

  1. 10.4
  2. 11.1
  3. 11.2
  4. 11.3
  5. 11.4
  6. 12.0
  7. 12.1
  8. 12.2
  9. 12.3
  10. 12.4
  11. 13.0–13.2
  12. 13.3–14.2
  13. 14.3–16.0

Standards

The thr_suspend() system call is non-standard.

History

The thr_suspend() system call first appeared in FreeBSD 5.2.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.