1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Xenomai API: File descriptors events multiplexing services.</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
<li>
<form action="search.php" method="get">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><label> <u>S</u>earch for </label></td>
<td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
</tr>
</table>
</form>
</li>
</ul>
</div>
</div>
<div class="contents">
<h1>File descriptors events multiplexing services.<br>
<small>
[<a class="el" href="group__nucleus.html">Xenomai nucleus.</a>]</small>
</h1>
<p>
<div class="dynheader">
Collaboration diagram for File descriptors events multiplexing services.:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__select.png" border="0" alt="" usemap="#group____select_map">
<map name="group____select_map">
<area shape="rect" href="group__nucleus.html" title="Xenomai nucleus." alt="" coords="5,5,141,32"></map></td></tr></table></center>
</div>
<hr><a name="_details"></a><h2>Detailed Description</h2>
File descriptors events multiplexing services.<p>
This module implements the services needed for implementing the posix "select" service, or any other events multiplexing services.<p>
Following the implementation of the posix select service, this module defines three types of events:<ul>
<li><em>XNSELECT_READ</em> meaning that a file descriptor is ready for reading;</li><li><em>XNSELECT_WRITE</em> meaning that a file descriptor is ready for writing;</li><li><em>XNSELECT_EXCEPT</em> meaning that a file descriptor received an exceptional event.</li></ul>
<p>
It works by defining two structures:<ul>
<li>a <em>struct</em> <em>xnselect</em> structure, which should be added to every file descriptor for every event type (read, write, or except);</li><li>a <em>struct</em> <em>xnselector</em> structure, the selection structure, passed by the thread calling the xnselect service, where this service does all its housekeeping. </li></ul>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Files</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file </td><td class="memItemRight" valign="bottom"><a class="el" href="select_8h.html">select.h</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">file descriptors events multiplexing header. <br></td></tr>
<p>
<tr><td class="memItemLeft" nowrap align="right" valign="top">file </td><td class="memItemRight" valign="bottom"><a class="el" href="select_8c.html">select.c</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">file descriptors events multiplexing. <br></td></tr>
<p>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__select.html#g80b33cc02e860dc6ffbd08e8da376e5b">xnselect_init</a> (struct xnselect *select_block)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Initialize a <em>struct</em> <em>xnselect</em> structure. <a href="#g80b33cc02e860dc6ffbd08e8da376e5b"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__select.html#g8546a4a6f997a8c29451673d5b7f0e86">xnselect_bind</a> (struct xnselect *select_block, struct xnselect_binding *binding, struct xnselector *selector, unsigned type, unsigned index, unsigned state)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Bind a file descriptor (represented by its <em>xnselect</em> structure) to a selector block. <a href="#g8546a4a6f997a8c29451673d5b7f0e86"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__select.html#g56e4b5bf3e35dd80c23e95cad8fa1614">xnselect_destroy</a> (struct xnselect *select_block)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destroy the <em>xnselect</em> structure associated with a file descriptor. <a href="#g56e4b5bf3e35dd80c23e95cad8fa1614"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__select.html#gf5576af13d5ffd6056311c2746a706a0">xnselector_init</a> (struct xnselector *selector)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Initialize a selector structure. <a href="#gf5576af13d5ffd6056311c2746a706a0"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__select.html#g4af23e0a42dbc61a04be36d5739a165f">xnselect</a> (struct xnselector *selector, fd_set *out_fds[XNSELECT_MAX_TYPES], fd_set *in_fds[XNSELECT_MAX_TYPES], int nfds, xnticks_t timeout, xntmode_t timeout_mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Check the state of a number of file descriptors, wait for a state change if no descriptor is ready. <a href="#g4af23e0a42dbc61a04be36d5739a165f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__select.html#g9f4741ca8d6794f1b45478a24b1104de">xnselector_destroy</a> (struct xnselector *selector)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destroy a selector block. <a href="#g9f4741ca8d6794f1b45478a24b1104de"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g4af23e0a42dbc61a04be36d5739a165f"></a><!-- doxytag: member="select.c::xnselect" ref="g4af23e0a42dbc61a04be36d5739a165f" args="(struct xnselector *selector, fd_set *out_fds[XNSELECT_MAX_TYPES], fd_set *in_fds[XNSELECT_MAX_TYPES], int nfds, xnticks_t timeout, xntmode_t timeout_mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int xnselect </td>
<td>(</td>
<td class="paramtype">struct xnselector * </td>
<td class="paramname"> <em>selector</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">fd_set * </td>
<td class="paramname"> <em>out_fds</em>[XNSELECT_MAX_TYPES], </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">fd_set * </td>
<td class="paramname"> <em>in_fds</em>[XNSELECT_MAX_TYPES], </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>nfds</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">xnticks_t </td>
<td class="paramname"> <em>timeout</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">xntmode_t </td>
<td class="paramname"> <em>timeout_mode</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Check the state of a number of file descriptors, wait for a state change if no descriptor is ready.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>selector</em> </td><td>structure to check for pending events </td></tr>
<tr><td valign="top"></td><td valign="top"><em>out_fds</em> </td><td>The set of descriptors with pending events if a strictly positive number is returned, or the set of descriptors not yet bound if -ECHRNG is returned; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>in_fds</em> </td><td>the set of descriptors which events should be checked </td></tr>
<tr><td valign="top"></td><td valign="top"><em>nfds</em> </td><td>the highest-numbered descriptor in any of the <em>in_fds</em> sets, plus 1; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>the timeout, whose meaning depends on <em>timeout_mode</em>, note that <a class="el" href="group__select.html#g4af23e0a42dbc61a04be36d5739a165f" title="Check the state of a number of file descriptors, wait for a state change if no descriptor...">xnselect()</a> pass <em>timeout</em> and <em>timeout_mode</em> unchanged to xnsynch_sleep_on, so passing a relative value different from XN_INFINITE as a timeout with <em>timeout_mode</em> set to XN_RELATIVE, will cause a longer sleep than expected if the sleep is interrupted. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout_mode</em> </td><td>the mode of <em>timeout</em>.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>-EINVAL</em> </td><td>if <em>nfds</em> is negative; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-ECHRNG</em> </td><td>if some of the descriptors passed in <em>in_fds</em> have not yet been registered with <a class="el" href="group__select.html#g8546a4a6f997a8c29451673d5b7f0e86" title="Bind a file descriptor (represented by its xnselect structure) to a selector block...">xnselect_bind()</a>, <em>out_fds</em> contains the set of such descriptors; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-EINTR</em> </td><td>if <em>xnselect</em> was interrupted while waiting; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>in case of timeout. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>the</em> </td><td>number of file descriptors having received an event. </td></tr>
</table>
</dl>
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00110">XNBREAK</a>, <a class="el" href="synch_8c-source.html#l00171">xnsynch_sleep_on()</a>, and <a class="el" href="include_2nucleus_2thread_8h-source.html#l00108">XNTIMEO</a>.</p>
</div>
</div><p>
<a class="anchor" name="g8546a4a6f997a8c29451673d5b7f0e86"></a><!-- doxytag: member="select.c::xnselect_bind" ref="g8546a4a6f997a8c29451673d5b7f0e86" args="(struct xnselect *select_block, struct xnselect_binding *binding, struct xnselector *selector, unsigned type, unsigned index, unsigned state)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int xnselect_bind </td>
<td>(</td>
<td class="paramtype">struct xnselect * </td>
<td class="paramname"> <em>select_block</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct xnselect_binding * </td>
<td class="paramname"> <em>binding</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct xnselector * </td>
<td class="paramname"> <em>selector</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned </td>
<td class="paramname"> <em>type</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned </td>
<td class="paramname"> <em>index</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned </td>
<td class="paramname"> <em>state</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Bind a file descriptor (represented by its <em>xnselect</em> structure) to a selector block.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>select_block</em> </td><td>pointer to the <em>struct</em> <em>xnselect</em> to be bound;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>binding</em> </td><td>pointer to a newly allocated (using xnmalloc) <em>struct</em> <em>xnselect_binding</em>;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>selector</em> </td><td>pointer to the selector structure;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>type</em> </td><td>type of events (<em>XNSELECT_READ</em>, <em>XNSELECT_WRITE</em>, or <em>XNSELECT_EXCEPT</em>);</td></tr>
<tr><td valign="top"></td><td valign="top"><em>index</em> </td><td>index of the file descriptor (represented by <em>select_block</em>) in the bit fields used by the <em>selector</em> structure;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>state</em> </td><td>current state of the file descriptor>.</td></tr>
</table>
</dl>
<em>select_block</em> must have been initialized with <a class="el" href="group__select.html#g80b33cc02e860dc6ffbd08e8da376e5b" title="Initialize a struct xnselect structure.">xnselect_init()</a>, the <em>xnselector</em> structure must have been initialized with <a class="el" href="group__select.html#gf5576af13d5ffd6056311c2746a706a0" title="Initialize a selector structure.">xnselector_init()</a>, <em>binding</em> may be uninitialized.<p>
This service must be called with nklock locked, irqs off. For this reason, the <em>binding</em> parameter must have been allocated by the caller outside the locking section.<p>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>-EINVAL</em> </td><td>if <em>type</em> or <em>index</em> is invalid; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>otherwise. </td></tr>
</table>
</dl>
<p>References <a class="el" href="pod_8h-source.html#l00251">xnpod_schedule()</a>.</p>
<p>Referenced by <a class="el" href="drvlib_8c-source.html#l01071">rtdm_event_select_bind()</a>, and <a class="el" href="drvlib_8c-source.html#l01353">rtdm_sem_select_bind()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g56e4b5bf3e35dd80c23e95cad8fa1614"></a><!-- doxytag: member="select.c::xnselect_destroy" ref="g56e4b5bf3e35dd80c23e95cad8fa1614" args="(struct xnselect *select_block)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnselect_destroy </td>
<td>(</td>
<td class="paramtype">struct xnselect * </td>
<td class="paramname"> <em>select_block</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destroy the <em>xnselect</em> structure associated with a file descriptor.
<p>
Any binding with a <em>xnselector</em> block is destroyed.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>select_block</em> </td><td>pointer to the <em>xnselect</em> structure associated with a file descriptor </td></tr>
</table>
</dl>
<p>References <a class="el" href="pod_8h-source.html#l00251">xnpod_schedule()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g80b33cc02e860dc6ffbd08e8da376e5b"></a><!-- doxytag: member="select.c::xnselect_init" ref="g80b33cc02e860dc6ffbd08e8da376e5b" args="(struct xnselect *select_block)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnselect_init </td>
<td>(</td>
<td class="paramtype">struct xnselect * </td>
<td class="paramname"> <em>select_block</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Initialize a <em>struct</em> <em>xnselect</em> structure.
<p>
This service must be called to initialize a <em>struct</em> <em>xnselect</em> structure before it is bound to a selector by the means of <a class="el" href="group__select.html#g8546a4a6f997a8c29451673d5b7f0e86" title="Bind a file descriptor (represented by its xnselect structure) to a selector block...">xnselect_bind()</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>select_block</em> </td><td>pointer to the xnselect structure to be initialized </td></tr>
</table>
</dl>
<p>Referenced by <a class="el" href="drvlib_8c-source.html#l00769">rtdm_event_init()</a>, and <a class="el" href="drvlib_8c-source.html#l01120">rtdm_sem_init()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g9f4741ca8d6794f1b45478a24b1104de"></a><!-- doxytag: member="select.c::xnselector_destroy" ref="g9f4741ca8d6794f1b45478a24b1104de" args="(struct xnselector *selector)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnselector_destroy </td>
<td>(</td>
<td class="paramtype">struct xnselector * </td>
<td class="paramname"> <em>selector</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destroy a selector block.
<p>
All bindings with file descriptor are destroyed.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>selector</em> </td><td>the selector block to be destroyed </td></tr>
</table>
</dl>
<p>References <a class="el" href="generic_2hal_8c-source.html#l00601">rthal_apc_schedule()</a>.</p>
<p>Referenced by <a class="el" href="pod_8c-source.html#l01078">xnpod_delete_thread()</a>.</p>
</div>
</div><p>
<a class="anchor" name="gf5576af13d5ffd6056311c2746a706a0"></a><!-- doxytag: member="select.c::xnselector_init" ref="gf5576af13d5ffd6056311c2746a706a0" args="(struct xnselector *selector)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int xnselector_init </td>
<td>(</td>
<td class="paramtype">struct xnselector * </td>
<td class="paramname"> <em>selector</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Initialize a selector structure.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>selector</em> </td><td>The selector structure to be initialized.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td></td></tr>
</table>
</dl>
<p>References <a class="el" href="synch_8c-source.html#l00102">xnsynch_init()</a>.</p>
</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Aug 2 12:48:38 2010 for Xenomai API by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>
|