SELRECORD(9)
π SELRECORD(9) π
okay bestie, welcome to the Kernel Developer's Manual β this one's about seldrain, selrecord and selwakeup, aka the three functions that make select(2) and poll(2) actually work. no cap, they're kind of the main characters. π
β¨ NAME β¨
seldrain, selrecord, selwakeup β record and wakeup select requests π«Ά
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/selinfo.h>
void
seldrain(struct selinfo *sip);
void
selrecord(struct thread *td, struct selinfo *sip);
void
selwakeup(struct selinfo *sip);
π¦ DESCRIPTION π¦
so. seldrain(), selrecord() and selwakeup() are the three central functions used by select(2), poll(2) and the objects that are being selected on. they literally handle the whole task of recording which threads are waiting on which objects, plus the waking of the proper threads when an event of interest occurs on an object. it's giving air traffic control but for kernel threads. βοΈ
selrecord() records that the calling thread is interested in events related to a given object. if another thread is already waiting on the object, a collision will be flagged in sip, which will be later dealt with by selwakeup(). drama? lowkey yes but it's handled. π
selrecord() acquires and releases sellock. π
selwakeup() is called by the underlying object handling code in order to notify any waiting threads that an event of interest has occurred. if a collision has occurred, selwakeup() will increment nselcoll, and broadcast on the global cv in order to wake all waiting threads so that they can handle it. if the thread waiting on the object is not currently sleeping, or the wait channel is not selwait, selwakeup() will clear the TDF_SELECT flag β which should be noted by select(2) and poll(2) when they wake up. noted, bestie. π
seldrain() will flush the waiters queue on a specified object before its destruction. the object handling code must ensure that *sip cannot be used once seldrain() has been called. like, don't touch it after, fr fr.
β οΈ the contents of*sipmust be zeroed, such as by softc initialization, before any call toselrecord()orselwakeup()β otherwise a panic may occur. not the fun kind of panic. the kernel kind. π zero it first!!
selwakeup() acquires and releases sellock and may acquire and release sched_lock. seldrain() could usually be just a wrapper for selwakeup(), but consumers should not generally rely on this feature. π
π SEE ALSO π
π AUTHORS π
this manual page was written by Chad David <davidc@FreeBSD.org> and Alfred Perlstein <alfred@FreeBSD.org>. legends, honestly. π
and that's the whole vibe check, bestie π§ this page came from Debian, dated August 25, 2011 β stan an oldie but a goodie. now go zero your *sip before you call anything, i'm begging you ππ
π¦ 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) 2002 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms