PTHREAD_MULTI_NP(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… PTHREAD_MULTI_NP(3) β€” bestie's guide to switching thread modes 🧡✨

okay so this is a page from the Library Functions Manual, and it lives in the POSIX Threads Library β€” aka libpthread, which you link with -lpthread. no cap, that's the whole vibe. 🫢


✨ NAME ✨

pthread_multi_np, pthread_single_np β€” the two functions that let you flip your process between multi-threaded and single-threaded scheduling modes. it's giving "pause the whole group chat" vs "resume the whole group chat", honestly. πŸŽ€


πŸ“š LIBRARY πŸ“š

POSIX Threads Library (libpthread, -lpthread) β€” the one and only. πŸ’–


🌸 SYNOPSIS 🌸

#include <pthread_np.h>

int
pthread_multi_np(void);

int
pthread_single_np(void);

two functions, zero arguments, and they both hand you back an int. simple. iconic. πŸ”₯


πŸ’« DESCRIPTION πŸ’«

so here's the tea. β˜•

  • pthread_single_np() β€” this one switches the whole process into single-threaded mode, which literally means it suspends all threads except the current one. yes, everybody else goes to sleep, you're the main character now. πŸ‘‘ the semantics of this function are similar to pthread_suspend_all_np(3).
  • pthread_multi_np() β€” and this one switches the process back into multi-threaded mode. everybody wakes up, the party resumes, we're all back in the group chat. 🌈 the semantics of this function are similar to pthread_resume_all_np(3).

that's it, that's the whole thing. no hidden agenda, no secret flags. πŸ¦‹


⭐ RETURN VALUES ⭐

pthread_multi_np() and the pthread_single_np functions always return 0. like, always. they don't do the error thing. zero is the whole personality. πŸ’€βœ¨


πŸ‘€ SEE ALSO πŸ‘€

go read those next, iykyk πŸ“–πŸ’œ


πŸŽ€ AUTHORS πŸŽ€

this manual page was written by Alexey Zelkin <phantom@FreeBSD.org>. absolute legend behavior, we stan. πŸ™ˆπŸ’…


tiny heads up, bestie: pthread_single_np() suspends all your other threads, so like… know what you're doing before you hit that. it's powerful and it's real. πŸ§šβ€β™€οΈ

okay that's the page!! source is Debian, dated October 12, 2021, and it's the PTHREAD_MULTI_NP(3) page β€” mwah, slayed, periodt. πŸ“πŸ’–πŸŽ€

πŸ“¦ where this page comes from