]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - share/man/man9/selrecord.9
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / share / man / man9 / selrecord.9
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 June 13, 2007
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
45 and
46 .Fn selwakeup
47 are the two central functions used by
48 .Xr select 2 ,
49 .Xr poll 2
50 and the objects that are being selected on.
51 They handle the task of recording which threads are waiting on which objects
52 and the waking of the proper threads when an event of interest occurs on an
53 object.
54 .Pp
55 .Fn selrecord
56 records that the calling thread is interested in events related to a given
57 object.
58 If another thread is already waiting on the object a collision will be flagged
59 in
60 .Fa sip
61 which will be later dealt with by
62 .Fn selwakeup .
63 .Pp
64 .Fn selrecord
65 acquires and releases
66 .Va sellock .
67 .Pp
68 .Fn selwakeup
69 is called by the underlying object handling code in order to notify any waiting
70 threads that an event of interest has occurred.
71 If a collision has occurred,
72 .Fn selwakeup
73 will increment
74 .Va nselcoll ,
75 and broadcast on the global cv in order to wake all waiting threads so that
76 they can handle it.
77 If the thread waiting on the object is not currently sleeping or the wait
78 channel is not
79 .Va selwait ,
80 .Fn selwakeup
81 will clear the
82 .Dv TDF_SELECT
83 flag which should be noted by
84 .Xr select 2
85 and
86 .Xr poll 2
87 when they wake up.
88 .Pp
89 The contents of
90 .Fa *sip
91 must be zeroed, such as by softc initialization, before any call to
92 .Fn selrecord
93 or
94 .Fn selwakeup ,
95 otherwise a panic may occur.
96 .Fn selwakeup
97 acquires and releases
98 .Va sellock
99 and may acquire and release
100 .Va sched_lock .
101 .Sh SEE ALSO
102 .Xr poll 2 ,
103 .Xr select 2
104 .Sh AUTHORS
105 .An -nosplit
106 This manual page was written by
107 .An Chad David Aq davidc@FreeBSD.org
108 and
109 .An Alfred Perlstein Aq alfred@FreeBSD.org .