1.\" 2.\" Copyright (C) 2002 Chad David <davidc@acns.ab.ca>. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice(s), this list of conditions and the following disclaimer as 9.\" the first lines of this file unmodified other than the possible 10.\" addition of one or more copyright notices. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice(s), this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 16.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25.\" DAMAGE. 26.\" 27.\" $FreeBSD$ 28.\" 29.Dd March 20, 2002 30.Dt SELRECORD 9 31.Os 32.Sh NAME 33.Nm selrecord , 34.Nm selwakeup 35.Nd "record and wakeup select requests" 36.Sh SYNOPSIS 37.In sys/param.h 38.In sys/selinfo.h 39.Ft void 40.Fn selrecord "struct thread *td" "struct selinfo *sip" 41.Ft void 42.Fn selwakeup "struct selinfo *sip" 43.Sh DESCRIPTION 44.Fn selrecord 45and 46.Fn selwakeup 47are the two central functions used by 48.Xr select 2 , 49.Xr poll 2 50and the objects that are being selected on. 51They handle the task of recording which threads are waiting on which objects 52and the waking of the proper threads when an event of interest occurs on an 53object. 54.Pp 55.Fn selrecord 56records that the calling thread is interested in events related to a given 57object. 58If another thread is already waiting on the object a collision will be flagged 59in 60.Fa sip 61which will be later dealt with by 62.Fn selwakeup . 63.Pp 64.Fn selrecord 65acquires and releases 66.Va sellock . 67.Pp 68.Fn selwakeup 69is called by the underlying object handling code in order to notify any waiting 70threads that an event of interest has occurred. 71If a collision has occurred, 72.Fn selwakeup 73will increment 74.Va nselcoll , 75and broadcast on the global cv in order to wake all waiting threads so that 76they can handle it. 77If the thread waiting on the object is not currently sleeping or the wait 78channel is not 79.Va selwait , 80.Fn selwakeup 81will clear the 82.Dv TDF_SELECT 83flag which should be noted by 84.Xr select 2 85and 86.Xr poll 2 87when they wake up. 88.Pp 89.Fn selwakeup 90acquires and releases 91.Va sellock 92and may acquire and release 93.Va sched_lock . 94.Sh SEE ALSO 95.Xr poll 2 , 96.Xr select 2 97.Sh AUTHORS 98.An -nosplit 99This man page was written by 100.An Chad David Aq davidc@FreeBSD.org 101and 102.An Alfred Perlstein Aq alfred@FreeBSD.org . 103