PHOLD(9)
π PHOLD β hold a process π
okay bestie, so we're in the kernel dev manual today and the whole vibe is: how do you keep a process from dipping out before you're done with it?? that's it. that's the page. let's get into it π«Ά
β¨ SYNOPSIS β¨
#include <sys/proc.h>
PHOLD(struct proc *p);
_PHOLD(struct proc *p);
PRELE(struct proc *p);
_PRELE(struct proc *p);
PROC_ASSERT_HELD(struct proc *p);
PROC_ASSERT_NOT_HELD(struct proc *p);
πΈ DESCRIPTION πΈ
so like. the PHOLD() macro bumps up the hold count of a process, and the PRELE() macro brings that hold count back down. that's the whole dynamic. it's giving β¨reference countingβ¨ but make it processes.
now here's the tea β β if a process with a non-zero hold count tries to exit, it does NOT get to leave. nope. it will sleep until its hold count hits zero, and only then does the kernel begin releasing resources associated with the process. it's literally waiting at the door like "bestie let me out" and the kernel is like "not until everyone lets go of you π".
which brings us to the very important part, and I need you to lock in for this one:
once a process has started exiting, it is invalid to increase its hold count. so callers must NOT attempt to hold a process that has the P_WEXIT flag set. no. don't. that's the rule. π
also, little fun fact for your notes app: the VM daemon will not swap out the kernel stack of a thread belonging to a process with a non-zero hold count. so while you're holding on, that stack is staying right where it is, no cap π
and the underscore twins!! the _PHOLD() and _PRELE() macros are identical to PHOLD() and PRELE() β same energy, same behavior β EXCEPT they must be called with the process lock held. that's the only difference. one (1) difference. periodt π
π AUTHORS π
this manual page was written by Mark Johnston <markj@FreeBSD.org>. iconic of him honestly π
okay and that's the whole page, bestie!! you're officially caught up on process holding πβ¨
Debian πΈ November 7, 2015 π¦ PHOLD(9) π mwah, go hold some processes responsibly π«Ά
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms