THR_SUSPEND(2)
THR_SUSPEND(2) β suspend the calling thread π
okay so this is a page from the System Calls Manual, and no cap, it's about one very specific little syscall. Grab a strawberry π and let's go.
π NAME π
thr_suspend β suspend the calling thread
π LIBRARY π
Standard C Library (libc, -lc)
πΈ SYNOPSIS πΈ
#include <sys/thr.h>
int
thr_suspend(struct timespec *timeout);
β¨ DESCRIPTION β¨
okay so first things first: 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. Like, that's the vibe for normal apps, bestie β this one is for threading implementation land.
The thr_suspend() system call puts the calling thread in a suspended state, where it is not eligible for CPU time. Iconic. This state is exited by:
- another thread calling
thr_wake(2), - when the time interval specified by
timeouthas 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. slay, no drama. π
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 thetimeoutargument is not valid.ETIMEDOUTβ The specifiedtimeoutexpired.ETIMEDOUTβ Thetimeoutargument specified a zero time interval.EINTRβ The sleep was interrupted by a signal.
π¦ SEE ALSO π¦
ps(1), thr_wake(2), pthread_resume_np(3), pthread_suspend_np(3)
π STANDARDS π
The thr_suspend() system call is non-standard. iykyk, it's a special little guy. π
π HISTORY π
The thr_suspend() system call first appeared in FreeBSD 5.2.
mwah π this page is from Debian, dated May 5, 2020 β THR_SUSPEND(2), periodt. π«Ά
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2016 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms