OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [fileio-select.html] - Blame information for rev 588

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
<!-- 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.               -->
9
<HTML
10
><HEAD
11
><TITLE
12
>Select</TITLE
13
><meta name="MSSmartTagsPreventParsing" content="TRUE">
14
<META
15
NAME="GENERATOR"
16
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17
"><LINK
18
REL="HOME"
19
TITLE="eCos Reference Manual"
20
HREF="ecos-ref.html"><LINK
21
REL="UP"
22
TITLE="File System Support Infrastructure"
23
HREF="fileio.html"><LINK
24
REL="PREVIOUS"
25
TITLE="Sockets"
26
HREF="fileio-sockets.html"><LINK
27
REL="NEXT"
28
TITLE="Devices"
29
HREF="fileio-devices.html"></HEAD
30
><BODY
31
CLASS="CHAPTER"
32
BGCOLOR="#FFFFFF"
33
TEXT="#000000"
34
LINK="#0000FF"
35
VLINK="#840084"
36
ALINK="#0000FF"
37
><DIV
38
CLASS="NAVHEADER"
39
><TABLE
40
SUMMARY="Header navigation table"
41
WIDTH="100%"
42
BORDER="0"
43
CELLPADDING="0"
44
CELLSPACING="0"
45
><TR
46
><TH
47
COLSPAN="3"
48
ALIGN="center"
49
>eCos Reference Manual</TH
50
></TR
51
><TR
52
><TD
53
WIDTH="10%"
54
ALIGN="left"
55
VALIGN="bottom"
56
><A
57
HREF="fileio-sockets.html"
58
ACCESSKEY="P"
59
>Prev</A
60
></TD
61
><TD
62
WIDTH="80%"
63
ALIGN="center"
64
VALIGN="bottom"
65
></TD
66
><TD
67
WIDTH="10%"
68
ALIGN="right"
69
VALIGN="bottom"
70
><A
71
HREF="fileio-devices.html"
72
ACCESSKEY="N"
73
>Next</A
74
></TD
75
></TR
76
></TABLE
77
><HR
78
ALIGN="LEFT"
79
WIDTH="100%"></DIV
80
><DIV
81
CLASS="CHAPTER"
82
><H1
83
><A
84
NAME="FILEIO-SELECT">Chapter 27. Select</H1
85
><P
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
89
><P
90
>The main part of the mechanism is the <TT
91
CLASS="FUNCTION"
92
>select()</TT
93
>
94
API call. This processes its arguments and calls the
95
<TT
96
CLASS="FUNCTION"
97
>fo_select()</TT
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
101
<TT
102
CLASS="FUNCTION"
103
>fo_select()</TT
104
> function will be called separately
105
for each appearance.</P
106
><P
107
>The <TT
108
CLASS="PARAMETER"
109
><I
110
>which</I
111
></TT
112
> argument of the
113
<TT
114
CLASS="FUNCTION"
115
>fo_select()</TT
116
> function will either be
117
<TT
118
CLASS="LITERAL"
119
>CYG_FREAD</TT
120
> to test for read conditions,
121
<TT
122
CLASS="LITERAL"
123
>CYG_FWRITE</TT
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
128
<TT
129
CLASS="FUNCTION"
130
>cyg_selrecord()</TT
131
> with the
132
<TT
133
CLASS="PARAMETER"
134
><I
135
>info</I
136
></TT
137
> argument that was passed to the function
138
and a pointer to a <SPAN
139
CLASS="STRUCTNAME"
140
>cyg_selinfo</SPAN
141
> structure.</P
142
><P
143
>The <SPAN
144
CLASS="STRUCTNAME"
145
>cyg_selinfo</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
149
CLASS="STRUCTNAME"
150
>cyg_selinfo</SPAN
151
>
152
structures should be kept for each of the options that the object can
153
select on - read, write or exception.</P
154
><P
155
>If none of the file objects report that the select condition is
156
satisfied, then the <TT
157
CLASS="FUNCTION"
158
>select()</TT
159
> API function puts
160
the calling thread to sleep waiting either for a condition to become
161
satisfied, or for the optional timeout to expire.</P
162
><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
167
CLASS="FUNCTION"
168
>cyg_selwakeup()</TT
169
> with a pointer to
170
the appropriate <SPAN
171
CLASS="STRUCTNAME"
172
>cyg_selinfo</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
177
<TT
178
CLASS="FUNCTION"
179
>select()</TT
180
> API call will return.</P
181
><P
182
>Note that <TT
183
CLASS="FUNCTION"
184
>select()</TT
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
191
></DIV
192
><DIV
193
CLASS="NAVFOOTER"
194
><HR
195
ALIGN="LEFT"
196
WIDTH="100%"><TABLE
197
SUMMARY="Footer navigation table"
198
WIDTH="100%"
199
BORDER="0"
200
CELLPADDING="0"
201
CELLSPACING="0"
202
><TR
203
><TD
204
WIDTH="33%"
205
ALIGN="left"
206
VALIGN="top"
207
><A
208
HREF="fileio-sockets.html"
209
ACCESSKEY="P"
210
>Prev</A
211
></TD
212
><TD
213
WIDTH="34%"
214
ALIGN="center"
215
VALIGN="top"
216
><A
217
HREF="ecos-ref.html"
218
ACCESSKEY="H"
219
>Home</A
220
></TD
221
><TD
222
WIDTH="33%"
223
ALIGN="right"
224
VALIGN="top"
225
><A
226
HREF="fileio-devices.html"
227
ACCESSKEY="N"
228
>Next</A
229
></TD
230
></TR
231
><TR
232
><TD
233
WIDTH="33%"
234
ALIGN="left"
235
VALIGN="top"
236
>Sockets</TD
237
><TD
238
WIDTH="34%"
239
ALIGN="center"
240
VALIGN="top"
241
><A
242
HREF="fileio.html"
243
ACCESSKEY="U"
244
>Up</A
245
></TD
246
><TD
247
WIDTH="33%"
248
ALIGN="right"
249
VALIGN="top"
250
>Devices</TD
251
></TR
252
></TABLE
253
></DIV
254
></BODY
255
></HTML
256
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.