pthread_yield(3)
π pthread_yield(3) π
okay bestie, gather round, we're talking about pthread_yield β straight out of the Library Functions Manual, and it lives in the POSIX threads library (libpthread, -lpthread) π§΅β¨
πΈ NAME πΈ
pthread_yield β yield the processor π«Ά
π LIBRARY π
POSIX threads library (libpthread, link it with -lpthread) π
β¨ SYNOPSIS β¨
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <pthread.h>
[[deprecated]] int pthread_yield(void);
yes bestie that [[deprecated]] is right there in the signature, it's giving π© not π, we'll get to why
π¦ DESCRIPTION π¦
Note: This function is deprecated; see below. π
okay so what does pthread_yield() actually do. It makes the calling thread relinquish the CPU πβ‘οΈπ. Like, the thread literally steps aside and is all "no you go, i insist". The thread gets placed at the end of the run queue for its static priority, and then another thread is scheduled to run. That's the whole vibe.
For further details, go read sched_yield(2) π (it's the whole entire personality of this function, fr fr).
π RETURN VALUE π
On success, pthread_yield() returns 0 β¨; on error, it returns an error number.
no cap, that's it. 0 means slayed, anything else is an error number.
π ERRORS π
On Linux, this call always succeeds β iconic, flawless, never misses π
(but portable and future-proof applications should nevertheless handle a possible error return, because the future is unpredictable and we don't do chaos here π«Ά)
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
- Interface:
pthread_yield() - Attribute: Thread safety
- Value:
MT-Safe
so yeah, she's MT-Safe, thread-safe besties, go wild π
π VERSIONS π
On Linux, this function is implemented as a call to sched_yield(2). That's it. That's the whole implementation. She's a middleman and she knows it π
β STANDARDS β
None.
literally none. zero. not a single standard claims her. it's giving "i'm not like the other functions" and not in a good way π
π§ HISTORY π§
Deprecated since glibc 2.34. Use the standardized sched_yield(2) instead π
like the glow-down was scheduled. the replacement was always coming.
π₯ NOTES π₯
okay this part actually matters so pay attention bestie:
pthread_yield() is intended for use with real-time scheduling policies β i.e., SCHED_FIFO or SCHED_RR β±οΈ
Use of pthread_yield() with nondeterministic scheduling policies such as SCHED_OTHER is unspecified and very likely means your application design is broken π
fr fr. if you're yielding on SCHED_OTHER, the manpage is not being mean, it's just being honest with you. that's a design smell, babes. π¨
π SEE ALSO π
and that's the whole page, bestie!! π this was Linux man-pages 6.20, dated 2026-02-08, and honestly she may be deprecated but she'll always be a little bit iconic to me πβ¨ slay, go yield responsibly, mwah π«Ά
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 2009, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms