Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

select(9) [netbsd man page]

SELECT(9)						   BSD Kernel Developer's Manual						 SELECT(9)

NAME
seldestroy, selinit, selrecord, selnotify -- select and poll subsystem SYNOPSIS
#include <sys/param.h> #include <sys/select.h> void seldestroy(struct selinfo *sip); void selinit(struct selinfo *sip); void selrecord(struct lwp *selector, struct selinfo *sip); void selnotify(struct selinfo *sip, int events, long knhint); DESCRIPTION
selinit() and seldestroy() functions must be used to initialize and destroy the struct selinfo. The seldestroy() function may block. selrecord() and selnotify() are used by device drivers to coordinate with the kernel implementation of select(2) and poll(2). Each object that can be polled contains a selinfo record. Device drivers provide locking for the selinfo record. selrecord() records that the calling thread is interested in events related to a given object. selrecord() should only be called when the poll routine determines that the object is not ready for I/O: there are no events of interest pending. The check for pending I/O and call to selrecord() must be atomic. Atomicity can be provided by holding the object's lock across the test and call to selrecord(). For non-MPSAFE drivers, the global kernel_lock is enough to provide atomicity. selnotify() is called by the underlying object handling code in order to notify any waiting threads that an event of interest has occurred. The same lock held across the poll method and call to selrecord() must be held across the call to selnotify(). The lock prevents an event of interest being signalled while a thread is in the process of recording its interest. The events indicates which event happen. Zero may be used if unknown. selnotify() also calls KNOTE() passing knhint as an argument. CODE REFERENCES
The core of the select and poll subsystem implementation is in sys/kern/sys_select.c. Data structures and function prototypes are located in sys/sys/select.h, sys/sys/poll.h and sys/sys/selinfo.h. SEE ALSO
poll(2), select(2), knote(9) BSD
May 13, 2008 BSD

Check Out this Related Man Page

chpoll(9E)							Driver Entry Points							chpoll(9E)

NAME
chpoll - poll entry point for a non-STREAMS character driver SYNOPSIS
#include <sys/types.h> #include <sys/poll.h> #include <sys/ddi.h> #include <sys/sunddi.h> int prefixchpoll(dev_t dev, short events, int anyyet, short *reventsp, struct pollhead **phpp); INTERFACE LEVEL
This entry point is optional. Architecture independent level 1 (DDI/DKI). PARAMETERS
dev The device number for the device to be polled. events The events that may occur. Valid events are: POLLIN Data other than high priority data may be read without blocking. POLLOUT Normal data may be written without blocking. POLLPRI High priority data may be received without blocking. POLLHUP A device hangup has occurred. POLLERR An error has occurred on the device. POLLRDNORM Normal data (priority band = 0) may be read without blocking. POLLRDBAND Data from a non-zero priority band may be read without blocking POLLWRNORM The same as POLLOUT. POLLWRBAND Priority data (priority band > 0) may be written. anyyet A flag that is non-zero if any other file descriptors in the pollfd array have events pending. The poll(2) system call takes a pointer to an array of pollfd structures as one of its arguments. See the poll(2) reference page for more details. reventsp A pointer to a bitmask of the returned events satisfied. phpp A pointer to a pointer to a pollhead structure. DESCRIPTION
The chpoll() entry point routine is used by non-STREAMS character device drivers that wish to support polling. The driver must implement the polling discipline itself. The following rules must be followed when implementing the polling discipline: 1. Implement the following algorithm when the chpoll() entry point is called: if (events_are_satisfied_now) { *reventsp = mask_of_satisfied_events; } else { *reventsp = 0; if (!anyyet) *phpp = &my_local_pollhead_structure; } return(0); 2. Allocate an instance of the pollhead structure. This instance may be tied to the per-minor data structure defined by the driver. The pollhead structure should be treated as a ``black box'' by the driver. None of its fields should be referenced. However, the size of this structure is guaranteed to remain the same across releases. 3. Call the pollwakeup() function whenever an event of type events listed above occur. This function can be called with multiple events at one time. The driver must not hold any mutex across the call to pollwakeup(9F) that is acquired in its chpoll() entry point, or a dead- lock may result. RETURN VALUES
chpoll() should return 0 for success, or the appropriate error number. SEE ALSO
poll(2), nochpoll(9F), pollwakeup(9F) Writing Device Drivers SunOS 5.10 8 Nov 2001 chpoll(9E)
Man Page