THR_WAKE(2)
π THR_WAKE(2) π
okay bestie, this is THR_WAKE(2) from the System Calls Manual, and it's giving tiny but important threading syscall energy. Let's get into it. π
β¨ NAME β¨
thr_wake β wake up the suspended thread. π«Ά
π LIBRARY π
Standard C Library (libc, -lc). yes, that's the one. β¨
π¦ SYNOPSIS π¦
#include <sys/thr.h>
int
thr_wake(long id);
πΈ 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. That's the recommended path, bestie β thr_wake() is more of an internal-tooling moment. π
Here's the tea. Passing the thread identifier of the calling thread (see thr_self(2)) 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). This is used by the system threading library to implement cancellation. periodt. β
If id is not equal to the current thread identifier, the specified thread is woken up if suspended by the thr_suspend(2) 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) results in immediate return with success. Only one wake is remembered. no stacking, no hoarding β just one lil wake note. π
π 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. simple as that. π
π₯ 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), thr_self(2), thr_suspend(2), pthread_cancel(3), pthread_resume_np(3), pthread_suspend_np(3)
π STANDARDS π
The thr_suspend() system call is non-standard and is used by 1:1 Threading Library (libthr, -lthr) to implement IEEE Std 1003.1-2001 (βPOSIX.1β) pthread(3) functionality. so yeah, non-standard icon behavior β keep that in mind. π§
π°οΈ HISTORY π°οΈ
The thr_suspend() system call first appeared in FreeBSD 5.2. iconic since day one, fr fr. β
That's the whole page, bestie. xoxo from your Debian girlie π
β this one is dated May 5, 2020, and it's the THR_WAKE(2) manual page. π
π¦ 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