1 .\" Copyright 2006 John-Mark Gurney
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm kqueue_add_filteropts , kqueue_del_filteropts ,
34 .Nm knlist_add , knlist_remove , knlist_remove_inevent , knlist_empty ,
35 .Nm knlist_init , knlist_destroy , knlist_clear , knlist_delete ,
36 .Nm KNOTE_LOCKED , KNOTE_UNLOCKED
37 .Nd "event delivery subsystem"
41 .Fn kqueue_add_filteropts "int filt" "struct filterops *filtops"
43 .Fn kqueue_del_filteropts "int filt"
45 .Fn kqfd_register "int fd" "struct kevent *kev" "struct thread *td" "int waitok"
47 .Fn knote_fdclose "struct thread *td" "int fd"
49 .Fn knlist_add "struct knlist *knl" "struct knote *kn" "int islocked"
51 .Fn knlist_remove "struct knlist *knl" "struct knote *kn" "int islocked"
53 .Fn knlist_remove_inevent "struct knlist *knl" "struct knote *kn"
55 .Fn knlist_empty "struct knlist *knl"
58 .Fa "struct knlist *knl"
60 .Fa "void \*[lp]*kl_lock\*[rp]\*[lp]void *\*[rp]"
61 .Fa "void \*[lp]*kl_unlock\*[rp]\*[lp]void *\*[rp]"
62 .Fa "int \*[lp]*kl_locked\*[rp]\*[lp]void *\*[rp]"
65 .Fn knlist_destroy "struct knlist *knl"
67 .Fn knlist_clear "struct knlist *knl" "int islocked"
69 .Fn knlist_delete "struct knlist *knl" "struct thread *td" "int islocked"
71 .Fn KNOTE_LOCKED "struct knlist *knl" "long hint"
73 .Fn KNOTE_UNLOCKED "struct knlist *knl" "long hint"
76 .Fn kqueue_add_filteropts
78 .Fn kqueue_del_filteropts
79 allow for the addition and removal of a filter type.
80 The filter is statically defined by the
84 .Fn kqueue_add_filteropts
89 .Vt "struct filterops"
90 has the following members:
91 .Bl -tag -width ".Va f_attach"
99 is taken to be a file descriptor.
106 member initialized to the
108 that represents the file descriptor.
112 function will be called when attaching a
115 The method should call
119 to the list that was initialized with
123 is only necessary if the object can have multiple
138 The function shall return 0 on success, or appropriate error for the failure.
141 it is valid to change the
143 pointer to a different pointer.
148 functions called when processing the
153 function will be called to detach the
157 has not already been detached by a call to
162 function will be called to update the status of the
164 If the function returns 0, it will be assumed that the object is not
165 ready (or no longer ready) to be woken up.
168 argument will be 0 when scanning
170 to see which are triggered.
173 argument will be the value passed to either
179 value should be updated as necessary to reflect the current value, such as
180 number of bytes available for reading, or buffer space available for writing.
181 If the note needs to be removed,
182 .Fn knlist_remove_inevent
185 .Fn knlist_remove_inevent
186 will remove the note from the list, the
188 function will not be called and the
190 will not be returned as an event.
196 If a lock is required in
198 it must be obtained in the
211 on the kqueue file descriptor
213 If it is safe to sleep,
219 is used to delete all
223 Once returned, there will no longer be any
229 removed will never be returned from a
231 call, so if userland uses the
233 to track resources, they will be leaked.
236 lock must be held over the call to
238 so that file descriptors cannot be added or removed.
242 family of functions are for managing
244 associated with an object.
247 is not required, but is commonly used.
250 must be initialized with the
257 an internal lock will be used and the remaining arguments will be ignored.
259 .Fa kl_lock , kl_unlock
262 functions will be used to manipulate a
266 default routines operating on
271 structure may be embedded into the object structure.
274 will be held over calls to
278 is passed for the mutex, a private mutex will be used.
286 is used to remove all
288 associated with the list.
296 will be marked as detached, and
298 will be set so that the
300 will be deleted after the next scan.
303 function is used to destroy a
313 may be attached to the object.
316 may be emptied by calling
325 about events associated with the object.
326 It will iterate over all
328 on the list calling the
330 function associated with the
334 must be used if the lock associated with the
339 will acquire the lock before iterating over the list of
343 .Fn kqueue_add_filteropts
344 will return zero on success,
346 in the case of an invalid
350 if the filter has already been installed.
353 .Fn kqueue_del_filteropts
354 will return zero on success,
356 in the case of an invalid
360 if the filter is still in use.
364 will return zero on success,
366 if the file descriptor is not a kqueue, or any of the possible values returned
374 manual page was written by
375 .An John-Mark Gurney Aq jmg@FreeBSD.org .