THREAD_EXIT(9)

okay so bestie, welcome to THREAD_EXIT(9) β€” the Kernel Developer's Manual page that's all about yeeting the current thread context πŸ’…βœ¨. If you're deep in kernel land and need to know how a thread says β€œbye, I’m out,” this is your girl. Let’s get into it.

πŸŽ€ NAME πŸŽ€

thread_exit β€” abandon current thread context πŸ¦‹

🌈 SYNOPSIS 🌈

#include <sys/param.h>
#include <sys/proc.h>

void
thread_exit(void);

πŸ’– DESCRIPTION πŸ’–

okay so thread_exit() is the machine independent prelude to a thread shutdown. It is literally the opening act before the thread dips. It will not return, no cap β€” instead it will result in a call to mi_switch(9) to schedule some other thread. So yeah, once you call it, you’re not coming back; the scheduler is picking the next main character. periodt ✨

thread_exit() also arranges to free all the resources of the thread, specifically the kernel stack. Iconic cleanup behavior, honestly. πŸ’…

To protect runqueue(9), thread_exit() must be called with the sched_lock mutex held. Do not skip this, bestie β€” the runqueue needs its protection. πŸ”’

πŸ‘‘ SEE ALSO πŸ‘‘


This page came from Debian, dated July 5, 2002, and it’s THREAD_EXIT(9). Slay, kernel thread, slay πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from