SELRECORD(9)
β¨ SELRECORD(9) β¨
okay so bestie, welcome to the kernel developer's manual π
this one's a 9 section page β that's the kernel internals zone, iykyk β and it's all about seldrain, selrecord, and selwakeup. these three are, like, the main character functions of the whole select/poll situation. let's get into it π«Ά
β¨ 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, and then waking the proper threads when an event of interest occurs on an object. no cap, that's the entire job π¦
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 insipwhich will be later dealt with byselwakeup(). also,selrecord()acquires and releasessellock. slay.selwakeup()β 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 incrementnselcoll, and broadcast on the globalcvin 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 notselwait,selwakeup()will clear theTDF_SELECTflag β which should be noted byselect(2)andpoll(2)when they wake up. iconic behaviour honestly.seldrain()β will flush the waiters queue on a specified object before its destruction. The object handling code must ensure that*sipcannot be used onceseldrain()has been called. like, that pointer is done, bestie π
The contents of*sipmust be zeroed β such as by softc initialization β before any call toselrecord()orselwakeup(), otherwise a panic may occur π don't skip this step fr fr.
Also: selwakeup() acquires and releases sellock and may acquire and release sched_lock. And seldrain() could usually be just a wrapper for selwakeup(), but consumers should not generally rely on this feature β that's a "you didn't hear it from me" situation π
β¨ SEE ALSO β¨
β¨ AUTHORS β¨
This manual page was written by Chad David <davidc@FreeBSD.org> and Alfred Perlstein <alfred@FreeBSD.org>. ty kings π
mwah, that's a wrap! π this little gem comes from the Debian page dated August 25, 2011 β oldie but a goodie, and it ate. go forth and wake your select requests responsibly, bestie πΈβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (C) 2002 Chad David <davidc@acns.ab.ca>. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms