1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="File System Support Infrastructure"
23 HREF="fileio.html"><LINK
26 HREF="fileio-sockets.html"><LINK
29 HREF="fileio-devices.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="fileio-sockets.html"
71 HREF="fileio-devices.html"
84 NAME="FILEIO-SELECT">Chapter 27. Select</H1
86 >The infrastructure provides support for implementing a select
87 mechanism. This is modeled on the mechanism in the BSD kernel, but has
88 been modified to make it implementation independent.</P
90 >The main part of the mechanism is the <TT
94 API call. This processes its arguments and calls the
98 > function pointer on all file objects
99 referenced by the file descriptor sets passed to it. If the same
100 descriptor appears in more than one descriptor set, the
104 > function will be called separately
105 for each appearance.</P
116 > function will either be
120 > to test for read conditions,
124 > to test for write conditions or zero to
125 test for exceptions. For each of these options the function should
126 test whether the condition is satisfied and if so return true. If it
127 is not satisfied then it should call
137 > argument that was passed to the function
138 and a pointer to a <SPAN
146 > structure is used to record information about current
147 select operations. Any object that needs to support select must
148 contain an instance of this structure. Separate <SPAN
152 structures should be kept for each of the options that the object can
153 select on - read, write or exception.</P
155 >If none of the file objects report that the select condition is
156 satisfied, then the <TT
160 the calling thread to sleep waiting either for a condition to become
161 satisfied, or for the optional timeout to expire.</P
163 >A selectable object must have some asynchronous activity that may
164 cause a select condition to become true - either via interrupts or the
165 activities of other threads. Whenever a selectable condition is
166 satisfied, the object should call <TT
170 the appropriate <SPAN
173 > structure. If the thread is still waiting,
174 this will cause it to wake up and repeat its poll of the file
175 descriptors. This time around, the object that caused the wakeup
176 should indicate that the select condition is satisfied, and the
180 > API call will return.</P
185 > does not exhibit real time
186 behaviour: the iterative poll of the descriptors, and the wakeup
187 mechanism mitigate against this. If real time response to device or
188 socket I/O is required then separate threads should be devoted to each
189 device of interest and should use blocking calls to wait for a
190 condition to become ready.</P
197 SUMMARY="Footer navigation table"
208 HREF="fileio-sockets.html"
226 HREF="fileio-devices.html"