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 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
|
<!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: include/nucleus/timer.h Source File</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 class="current"><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>
<h1>include/nucleus/timer.h</h1><a href="include_2nucleus_2timer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef _XENO_NUCLEUS_TIMER_H</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define _XENO_NUCLEUS_TIMER_H</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#include <<a class="code" href="timebase_8h.html">nucleus/timebase.h</a>></span>
<a name="l00027"></a>00027 <span class="preprocessor">#include <nucleus/stat.h></span>
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="preprocessor">#if defined(__KERNEL__) || defined(__XENO_SIM__)</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#ifndef CONFIG_XENO_OPT_DEBUG_TIMERS</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define CONFIG_XENO_OPT_DEBUG_TIMERS 0</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#define XNTIMER_WHEELSIZE 64</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_WHEELMASK (XNTIMER_WHEELSIZE - 1)</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="comment">/* Timer status */</span>
<a name="l00039"></a>00039 <span class="preprocessor">#define XNTIMER_DEQUEUED 0x00000001</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_KILLED 0x00000002</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_PERIODIC 0x00000004</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_REALTIME 0x00000008</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_FIRED 0x00000010</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_NOBLCK 0x00000020</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>
<a name="l00046"></a>00046 <span class="comment">/* These flags are available to the real-time interfaces */</span>
<a name="l00047"></a>00047 <span class="preprocessor">#define XNTIMER_SPARE0 0x01000000</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE1 0x02000000</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE2 0x04000000</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE3 0x08000000</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE4 0x10000000</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE5 0x20000000</span>
<a name="l00053"></a>00053 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE6 0x40000000</span>
<a name="l00054"></a>00054 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_SPARE7 0x80000000</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span>
<a name="l00056"></a>00056 <span class="comment">/* Timer priorities */</span>
<a name="l00057"></a>00057 <span class="preprocessor">#define XNTIMER_LOPRIO (-999999999)</span>
<a name="l00058"></a>00058 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_STDPRIO 0</span>
<a name="l00059"></a>00059 <span class="preprocessor"></span><span class="preprocessor">#define XNTIMER_HIPRIO 999999999</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span>
<a name="l00061"></a>00061 <span class="preprocessor">#define XNTIMER_KEEPER_ID 0</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span>
<a name="l00063"></a>00063 <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00064"></a>00064 xnholder_t link;
<a name="l00065"></a>00065 xnticks_t key;
<a name="l00066"></a>00066 <span class="keywordtype">int</span> prio;
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="preprocessor">#define link2tlholder(ln) container_of(ln, xntlholder_t, link)</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span>
<a name="l00070"></a>00070 } xntlholder_t;
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="preprocessor">#define xntlholder_date(h) ((h)->key)</span>
<a name="l00073"></a>00073 <span class="preprocessor"></span><span class="preprocessor">#define xntlholder_prio(h) ((h)->prio)</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#define xntlholder_init(h) inith(&(h)->link)</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span><span class="preprocessor">#define xntlist_init(q) initq(q)</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span><span class="preprocessor">#define xntlist_head(q) \</span>
<a name="l00077"></a>00077 <span class="preprocessor"> ({ xnholder_t *_h = getheadq(q); \</span>
<a name="l00078"></a>00078 <span class="preprocessor"> !_h ? NULL : link2tlholder(_h); \</span>
<a name="l00079"></a>00079 <span class="preprocessor"> })</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span>
<a name="l00081"></a>00081 <span class="preprocessor">#define xntlist_next(q, h) \</span>
<a name="l00082"></a>00082 <span class="preprocessor"> ({ xnholder_t *_h = nextq(q, &(h)->link); \</span>
<a name="l00083"></a>00083 <span class="preprocessor"> !_h ? NULL : link2tlholder(_h); \</span>
<a name="l00084"></a>00084 <span class="preprocessor"> })</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>
<a name="l00086"></a>00086 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> xntlist_insert(xnqueue_t *q, xntlholder_t *holder)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 xnholder_t *p;
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <span class="comment">/* Insert the new timer at the proper place in the single</span>
<a name="l00091"></a>00091 <span class="comment"> queue managed when running in aperiodic mode. O(N) here,</span>
<a name="l00092"></a>00092 <span class="comment"> but users of the aperiodic mode need to pay a price for the</span>
<a name="l00093"></a>00093 <span class="comment"> increased flexibility... */</span>
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="keywordflow">for</span> (p = q->head.last; p != &q->head; p = p->last)
<a name="l00096"></a>00096 <span class="keywordflow">if</span> ((xnsticks_t) (holder->key - link2tlholder(p)->key) > 0 ||
<a name="l00097"></a>00097 (holder->key == link2tlholder(p)->key &&
<a name="l00098"></a>00098 holder->prio <= link2tlholder(p)->prio))
<a name="l00099"></a>00099 <span class="keywordflow">break</span>;
<a name="l00100"></a>00100
<a name="l00101"></a>00101 insertq(q,p->next,&holder->link);
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="preprocessor">#define xntlist_remove(q, h) removeq((q),&(h)->link)</span>
<a name="l00105"></a>00105 <span class="preprocessor"></span>
<a name="l00106"></a>00106 <span class="preprocessor">#if defined(CONFIG_XENO_OPT_TIMER_HEAP)</span>
<a name="l00107"></a>00107 <span class="preprocessor"></span>
<a name="l00108"></a>00108 <span class="preprocessor">#include <nucleus/bheap.h></span>
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="keyword">typedef</span> bheaph_t xntimerh_t;
<a name="l00111"></a>00111
<a name="l00112"></a>00112 <span class="preprocessor">#define xntimerh_date(h) bheaph_key(h)</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span><span class="preprocessor">#define xntimerh_prio(h) bheaph_prio(h)</span>
<a name="l00114"></a>00114 <span class="preprocessor"></span><span class="preprocessor">#define xntimerh_init(h) bheaph_init(h)</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span>
<a name="l00116"></a>00116 <span class="keyword">typedef</span> DECLARE_BHEAP_CONTAINER(xntimerq_t, CONFIG_XENO_OPT_TIMER_HEAP_CAPACITY);
<a name="l00117"></a>00117
<a name="l00118"></a>00118 <span class="preprocessor">#define xntimerq_init(q) bheap_init((q), CONFIG_XENO_OPT_TIMER_HEAP_CAPACITY)</span>
<a name="l00119"></a>00119 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_destroy(q) bheap_destroy(q)</span>
<a name="l00120"></a>00120 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_head(q) bheap_gethead(q)</span>
<a name="l00121"></a>00121 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_insert(q, h) bheap_insert((q),(h))</span>
<a name="l00122"></a>00122 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_remove(q, h) bheap_delete((q),(h))</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span>
<a name="l00124"></a>00124 <span class="keyword">typedef</span> <span class="keyword">struct </span>{} xntimerq_it_t;
<a name="l00125"></a>00125
<a name="l00126"></a>00126 <span class="preprocessor">#define xntimerq_it_begin(q, i) ((void) (i), bheap_gethead(q))</span>
<a name="l00127"></a>00127 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_it_next(q, i, h) ((void) (i), bheap_next((q),(h)))</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span>
<a name="l00129"></a>00129 <span class="preprocessor">#elif defined(CONFIG_XENO_OPT_TIMER_WHEEL)</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span>
<a name="l00131"></a>00131 <span class="keyword">typedef</span> xntlholder_t xntimerh_t;
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="preprocessor">#define xntimerh_date(h) xntlholder_date(h)</span>
<a name="l00134"></a>00134 <span class="preprocessor"></span><span class="preprocessor">#define xntimerh_prio(h) xntlholder_prio(h)</span>
<a name="l00135"></a>00135 <span class="preprocessor"></span><span class="preprocessor">#define xntimerh_init(h) xntlholder_init(h)</span>
<a name="l00136"></a>00136 <span class="preprocessor"></span>
<a name="l00137"></a>00137 <span class="keyword">typedef</span> <span class="keyword">struct </span>xntimerq {
<a name="l00138"></a>00138 <span class="keywordtype">unsigned</span> date_shift;
<a name="l00139"></a>00139 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> next_shot;
<a name="l00140"></a>00140 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> shot_wrap;
<a name="l00141"></a>00141 xnqueue_t bucket[XNTIMER_WHEELSIZE];
<a name="l00142"></a>00142 } xntimerq_t;
<a name="l00143"></a>00143
<a name="l00144"></a>00144 <span class="keyword">typedef</span> <span class="keyword">struct </span>xntimerq_it {
<a name="l00145"></a>00145 <span class="keywordtype">unsigned</span> bucket;
<a name="l00146"></a>00146 } xntimerq_it_t;
<a name="l00147"></a>00147
<a name="l00148"></a>00148 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> xntimerq_init(xntimerq_t *q)
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> step_tsc;
<a name="l00151"></a>00151 <span class="keywordtype">unsigned</span> i;
<a name="l00152"></a>00152
<a name="l00153"></a>00153 step_tsc = xnarch_ns_to_tsc(CONFIG_XENO_OPT_TIMER_WHEEL_STEP);
<a name="l00154"></a>00154 <span class="comment">/* q->date_shift = fls(step_tsc); */</span>
<a name="l00155"></a>00155 <span class="keywordflow">for</span> (q->date_shift = 0; (1 << q->date_shift) < step_tsc; q->date_shift++)
<a name="l00156"></a>00156 ;
<a name="l00157"></a>00157 q->next_shot = q->shot_wrap = ((~0ULL) >> q->date_shift) + 1;
<a name="l00158"></a>00158 <span class="keywordflow">for</span> (i = 0; i < <span class="keyword">sizeof</span>(q->bucket)/<span class="keyword">sizeof</span>(xnqueue_t); i++)
<a name="l00159"></a>00159 xntlist_init(&q->bucket[i]);
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161
<a name="l00162"></a>00162 <span class="preprocessor">#define xntimerq_destroy(q) do { } while (0)</span>
<a name="l00163"></a>00163 <span class="preprocessor"></span>
<a name="l00164"></a>00164 <span class="keyword">static</span> <span class="keyword">inline</span> xntlholder_t *xntimerq_head(xntimerq_t *q)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166 <span class="keywordtype">unsigned</span> bucket = ((unsigned) q->next_shot) & XNTIMER_WHEELMASK;
<a name="l00167"></a>00167 xntlholder_t *result;
<a name="l00168"></a>00168 <span class="keywordtype">unsigned</span> i;
<a name="l00169"></a>00169
<a name="l00170"></a>00170 <span class="keywordflow">if</span> (q->next_shot == q->shot_wrap)
<a name="l00171"></a>00171 <span class="keywordflow">return</span> NULL;
<a name="l00172"></a>00172
<a name="l00173"></a>00173 result = xntlist_head(&q->bucket[bucket]);
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keywordflow">if</span> (result && (xntlholder_date(result) >> q->date_shift) == q->next_shot)
<a name="l00176"></a>00176 <span class="keywordflow">return</span> result;
<a name="l00177"></a>00177
<a name="l00178"></a>00178 <span class="comment">/* We could not find the next timer in the first bucket, iterate over</span>
<a name="l00179"></a>00179 <span class="comment"> the other buckets. */</span>
<a name="l00180"></a>00180 <span class="keywordflow">for</span> (i = (bucket + 1) & XNTIMER_WHEELMASK ;
<a name="l00181"></a>00181 i != bucket; i = (i + 1) & XNTIMER_WHEELMASK) {
<a name="l00182"></a>00182 xntlholder_t *candidate = xntlist_head(&q->bucket[i]);
<a name="l00183"></a>00183
<a name="l00184"></a>00184 <span class="keywordflow">if</span>(++q->next_shot == q->shot_wrap)
<a name="l00185"></a>00185 q->next_shot = 0;
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="keywordflow">if</span> (!candidate)
<a name="l00188"></a>00188 <span class="keywordflow">continue</span>;
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="keywordflow">if</span> ((xntlholder_date(candidate) >> q->date_shift) == q->next_shot)
<a name="l00191"></a>00191 <span class="keywordflow">return</span> candidate;
<a name="l00192"></a>00192
<a name="l00193"></a>00193 <span class="keywordflow">if</span> (!result || (xnsticks_t) (xntlholder_date(candidate)
<a name="l00194"></a>00194 - xntlholder_date(result)) < 0)
<a name="l00195"></a>00195 result = candidate;
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <span class="keywordflow">if</span> (result)
<a name="l00199"></a>00199 q->next_shot = (xntlholder_date(result) >> q->date_shift);
<a name="l00200"></a>00200 <span class="keywordflow">else</span>
<a name="l00201"></a>00201 q->next_shot = q->shot_wrap;
<a name="l00202"></a>00202 <span class="keywordflow">return</span> result;
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204
<a name="l00205"></a>00205 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> xntimerq_insert(xntimerq_t *q, xntimerh_t *h)
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> shifted_date = xntlholder_date(h) >> q->date_shift;
<a name="l00208"></a>00208 <span class="keywordtype">unsigned</span> bucket = ((unsigned) shifted_date) & XNTIMER_WHEELMASK;
<a name="l00209"></a>00209
<a name="l00210"></a>00210 <span class="keywordflow">if</span> ((<span class="keywordtype">long</span> <span class="keywordtype">long</span>) (shifted_date - q->next_shot) < 0)
<a name="l00211"></a>00211 q->next_shot = shifted_date;
<a name="l00212"></a>00212 xntlist_insert(&q->bucket[bucket], h);
<a name="l00213"></a>00213 }
<a name="l00214"></a>00214
<a name="l00215"></a>00215 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> xntimerq_remove(xntimerq_t *q, xntimerh_t *h)
<a name="l00216"></a>00216 {
<a name="l00217"></a>00217 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> shifted_date = xntlholder_date(h) >> q->date_shift;
<a name="l00218"></a>00218 <span class="keywordtype">unsigned</span> bucket = ((unsigned) shifted_date) & XNTIMER_WHEELMASK;
<a name="l00219"></a>00219
<a name="l00220"></a>00220 xntlist_remove(&q->bucket[bucket], h);
<a name="l00221"></a>00221 <span class="comment">/* Do not attempt to update q->next_shot, xntimerq_head will recover. */</span>
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223
<a name="l00224"></a>00224 <span class="keyword">static</span> <span class="keyword">inline</span> xntimerh_t *xntimerq_it_begin(xntimerq_t *q, xntimerq_it_t *it)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226 xntimerh_t *holder = NULL;
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="keywordflow">for</span> (it->bucket = 0; it->bucket < XNTIMER_WHEELSIZE; it->bucket++)
<a name="l00229"></a>00229 <span class="keywordflow">if</span> ((holder = xntlist_head(&q->bucket[it->bucket])))
<a name="l00230"></a>00230 <span class="keywordflow">break</span>;
<a name="l00231"></a>00231
<a name="l00232"></a>00232 <span class="keywordflow">return</span> holder;
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234
<a name="l00235"></a>00235 <span class="keyword">static</span> <span class="keyword">inline</span> xntimerh_t *
<a name="l00236"></a>00236 xntimerq_it_next(xntimerq_t *q, xntimerq_it_t *it, xntimerh_t *holder)
<a name="l00237"></a>00237 {
<a name="l00238"></a>00238 xntimerh_t *next = xntlist_next(&q->bucket[it->bucket], holder);
<a name="l00239"></a>00239
<a name="l00240"></a>00240 <span class="keywordflow">if</span> (!next)
<a name="l00241"></a>00241 <span class="keywordflow">for</span>(it->bucket++; it->bucket < XNTIMER_WHEELSIZE; it->bucket++)
<a name="l00242"></a>00242 <span class="keywordflow">if</span> ((next = xntlist_head(&q->bucket[it->bucket])))
<a name="l00243"></a>00243 <span class="keywordflow">break</span>;
<a name="l00244"></a>00244
<a name="l00245"></a>00245 <span class="keywordflow">return</span> next;
<a name="l00246"></a>00246 }
<a name="l00247"></a>00247
<a name="l00248"></a>00248 <span class="preprocessor">#else </span><span class="comment">/* CONFIG_XENO_OPT_TIMER_LIST */</span>
<a name="l00249"></a>00249
<a name="l00250"></a>00250 <span class="keyword">typedef</span> xntlholder_t xntimerh_t;
<a name="l00251"></a>00251
<a name="l00252"></a>00252 <span class="preprocessor">#define xntimerh_date(h) xntlholder_date(h)</span>
<a name="l00253"></a>00253 <span class="preprocessor"></span><span class="preprocessor">#define xntimerh_prio(h) xntlholder_prio(h)</span>
<a name="l00254"></a>00254 <span class="preprocessor"></span><span class="preprocessor">#define xntimerh_init(h) xntlholder_init(h)</span>
<a name="l00255"></a>00255 <span class="preprocessor"></span>
<a name="l00256"></a>00256 <span class="keyword">typedef</span> xnqueue_t xntimerq_t;
<a name="l00257"></a>00257
<a name="l00258"></a>00258 <span class="preprocessor">#define xntimerq_init(q) xntlist_init(q)</span>
<a name="l00259"></a>00259 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_destroy(q) do { } while (0)</span>
<a name="l00260"></a>00260 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_head(q) xntlist_head(q)</span>
<a name="l00261"></a>00261 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_insert(q,h) xntlist_insert((q),(h))</span>
<a name="l00262"></a>00262 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_remove(q, h) xntlist_remove((q),(h))</span>
<a name="l00263"></a>00263 <span class="preprocessor"></span>
<a name="l00264"></a>00264 <span class="keyword">typedef</span> <span class="keyword">struct </span>{} xntimerq_it_t;
<a name="l00265"></a>00265
<a name="l00266"></a>00266 <span class="preprocessor">#define xntimerq_it_begin(q,i) ((void) (i), xntlist_head(q))</span>
<a name="l00267"></a>00267 <span class="preprocessor"></span><span class="preprocessor">#define xntimerq_it_next(q,i,h) ((void) (i), xntlist_next((q),(h)))</span>
<a name="l00268"></a>00268 <span class="preprocessor"></span>
<a name="l00269"></a>00269 <span class="preprocessor">#endif </span><span class="comment">/* CONFIG_XENO_OPT_TIMER_LIST */</span>
<a name="l00270"></a>00270
<a name="l00271"></a>00271 <span class="keyword">struct </span><a class="code" href="structxnsched.html" title="Scheduling information structure.">xnsched</a>;
<a name="l00272"></a>00272
<a name="l00273"></a>00273 <span class="keyword">typedef</span> <span class="keyword">struct </span>xntimer {
<a name="l00274"></a>00274
<a name="l00275"></a>00275 xntimerh_t aplink; <span class="comment">/* Link in aperiodic timers list. */</span>
<a name="l00276"></a>00276
<a name="l00277"></a>00277 <span class="preprocessor">#define aplink2timer(ln) container_of(ln, xntimer_t, aplink)</span>
<a name="l00278"></a>00278 <span class="preprocessor"></span>
<a name="l00279"></a>00279 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_TIMING_PERIODIC</span>
<a name="l00280"></a>00280 <span class="preprocessor"></span> xntbase_t *base; <span class="comment">/* Time base. */</span>
<a name="l00281"></a>00281
<a name="l00282"></a>00282 xntlholder_t plink; <span class="comment">/* Link in periodic timers wheel. */</span>
<a name="l00283"></a>00283
<a name="l00284"></a>00284 <span class="preprocessor">#define plink2timer(ln) container_of(ln, xntimer_t, plink)</span>
<a name="l00285"></a>00285 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* CONFIG_XENO_OPT_TIMING_PERIODIC */</span>
<a name="l00286"></a>00286
<a name="l00287"></a>00287 xnholder_t adjlink;
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <span class="preprocessor">#define adjlink2timer(ln) container_of(ln, xntimer_t, adjlink)</span>
<a name="l00290"></a>00290 <span class="preprocessor"></span>
<a name="l00291"></a>00291 xnflags_t status; <span class="comment">/* !< Timer status. */</span>
<a name="l00292"></a>00292
<a name="l00293"></a>00293 xnticks_t interval; <span class="comment">/* !< Periodic interval (in ticks, 0 == one shot). */</span>
<a name="l00294"></a>00294
<a name="l00295"></a>00295 xnticks_t pexpect; <span class="comment">/* !< Date of next periodic release point (raw ticks). */</span>
<a name="l00296"></a>00296
<a name="l00297"></a>00297 <span class="keyword">struct </span><a class="code" href="structxnsched.html" title="Scheduling information structure.">xnsched</a> *sched; <span class="comment">/* !< Sched structure to which the timer is</span>
<a name="l00298"></a>00298 <span class="comment"> attached. */</span>
<a name="l00299"></a>00299
<a name="l00300"></a>00300 void (*handler)(<span class="keyword">struct </span>xntimer *timer); <span class="comment">/* !< Timeout handler. */</span>
<a name="l00301"></a>00301
<a name="l00302"></a>00302 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_STATS</span>
<a name="l00303"></a>00303 <span class="preprocessor"></span> <span class="keywordtype">char</span> name[XNOBJECT_NAME_LEN]; <span class="comment">/* !< Timer name to be displayed. */</span>
<a name="l00304"></a>00304
<a name="l00305"></a>00305 <span class="keyword">const</span> <span class="keywordtype">char</span> *handler_name; <span class="comment">/* !< Handler name to be displayed. */</span>
<a name="l00306"></a>00306
<a name="l00307"></a>00307 xnholder_t tblink; <span class="comment">/* !< Timer holder in timebase. */</span>
<a name="l00308"></a>00308
<a name="l00309"></a>00309 <span class="preprocessor">#define tblink2timer(ln) container_of(ln, xntimer_t, tblink)</span>
<a name="l00310"></a>00310 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* CONFIG_XENO_OPT_STATS */</span>
<a name="l00311"></a>00311
<a name="l00312"></a>00312 xnstat_counter_t scheduled; <span class="comment">/* !< Number of timer schedules. */</span>
<a name="l00313"></a>00313
<a name="l00314"></a>00314 xnstat_counter_t fired; <span class="comment">/* !< Number of timer events. */</span>
<a name="l00315"></a>00315
<a name="l00316"></a>00316 XNARCH_DECL_DISPLAY_CONTEXT();
<a name="l00317"></a>00317
<a name="l00318"></a>00318 } xntimer_t;
<a name="l00319"></a>00319
<a name="l00320"></a>00320 <span class="keyword">typedef</span> <span class="keyword">struct </span>xntimed_slave {
<a name="l00321"></a>00321
<a name="l00322"></a>00322 xntbase_t base; <span class="comment">/* !< Cascaded time base. */</span>
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <span class="keyword">struct </span>percpu_cascade {
<a name="l00325"></a>00325 xntimer_t timer; <span class="comment">/* !< Cascading timer in master time base. */</span>
<a name="l00326"></a>00326 xnqueue_t wheel[XNTIMER_WHEELSIZE];
<a name="l00327"></a>00327 } cascade[XNARCH_NR_CPUS];
<a name="l00328"></a>00328
<a name="l00329"></a>00329 <span class="preprocessor">#define timer2slave(t) \</span>
<a name="l00330"></a>00330 <span class="preprocessor"> ((xntslave_t *)(((char *)t) - offsetof(xntslave_t, cascade[xnsched_cpu((t)->sched)].timer)))</span>
<a name="l00331"></a>00331 <span class="preprocessor"></span><span class="preprocessor">#define base2slave(b) \</span>
<a name="l00332"></a>00332 <span class="preprocessor"> ((xntslave_t *)(((char *)b) - offsetof(xntslave_t, base)))</span>
<a name="l00333"></a>00333 <span class="preprocessor"></span>
<a name="l00334"></a>00334 } xntslave_t;
<a name="l00335"></a>00335
<a name="l00336"></a>00336 <span class="preprocessor">#ifdef CONFIG_SMP</span>
<a name="l00337"></a>00337 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_sched(t) ((t)->sched)</span>
<a name="l00338"></a>00338 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* !CONFIG_SMP */</span>
<a name="l00339"></a>00339 <span class="preprocessor">#define xntimer_sched(t) xnpod_current_sched()</span>
<a name="l00340"></a>00340 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !CONFIG_SMP */</span>
<a name="l00341"></a>00341 <span class="preprocessor">#define xntimer_interval(t) ((t)->interval)</span>
<a name="l00342"></a>00342 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_pexpect(t) ((t)->pexpect)</span>
<a name="l00343"></a>00343 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_pexpect_forward(t,delta) ((t)->pexpect += delta)</span>
<a name="l00344"></a>00344 <span class="preprocessor"></span>
<a name="l00345"></a>00345 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_TIMING_PERIODIC</span>
<a name="l00346"></a>00346 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_base(t) ((t)->base)</span>
<a name="l00347"></a>00347 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_set_priority(t,p) \</span>
<a name="l00348"></a>00348 <span class="preprocessor"> ({ \</span>
<a name="l00349"></a>00349 <span class="preprocessor"> xntimer_t *_t = (t); \</span>
<a name="l00350"></a>00350 <span class="preprocessor"> unsigned prio = (p); \</span>
<a name="l00351"></a>00351 <span class="preprocessor"> xntimerh_prio(&(_t)->aplink) = prio; \</span>
<a name="l00352"></a>00352 <span class="preprocessor"> xntlholder_prio(&(_t)->plink) = prio; \</span>
<a name="l00353"></a>00353 <span class="preprocessor"> })</span>
<a name="l00354"></a>00354 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* !CONFIG_XENO_OPT_TIMING_PERIODIC */</span>
<a name="l00355"></a>00355 <span class="preprocessor">#define xntimer_base(t) (&nktbase)</span>
<a name="l00356"></a>00356 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_set_priority(t,p) \</span>
<a name="l00357"></a>00357 <span class="preprocessor"> do { xntimerh_prio(&(t)->aplink) = (p); } while(0)</span>
<a name="l00358"></a>00358 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !CONFIG_XENO_OPT_TIMING_PERIODIC */</span>
<a name="l00359"></a>00359
<a name="l00360"></a>00360 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> xntimer_active_p (xntimer_t *timer)
<a name="l00361"></a>00361 {
<a name="l00362"></a>00362 <span class="keywordflow">return</span> timer->sched != NULL;
<a name="l00363"></a>00363 }
<a name="l00364"></a>00364
<a name="l00365"></a>00365 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> xntimer_running_p(xntimer_t *timer)
<a name="l00366"></a>00366 {
<a name="l00367"></a>00367 <span class="keywordflow">return</span> !testbits(timer->status,XNTIMER_DEQUEUED);
<a name="l00368"></a>00368 }
<a name="l00369"></a>00369
<a name="l00370"></a>00370 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> xntimer_reload_p(xntimer_t *timer)
<a name="l00371"></a>00371 {
<a name="l00372"></a>00372 <span class="keywordflow">return</span> testbits(timer->status,
<a name="l00373"></a>00373 XNTIMER_PERIODIC|XNTIMER_DEQUEUED|XNTIMER_KILLED) ==
<a name="l00374"></a>00374 (XNTIMER_PERIODIC|XNTIMER_DEQUEUED);
<a name="l00375"></a>00375 }
<a name="l00376"></a>00376
<a name="l00377"></a>00377 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00378"></a>00378 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
<a name="l00379"></a>00379 <span class="preprocessor">#endif</span>
<a name="l00380"></a>00380 <span class="preprocessor"></span>
<a name="l00381"></a>00381 <span class="keyword">extern</span> xntbops_t nktimer_ops_aperiodic,
<a name="l00382"></a>00382 nktimer_ops_periodic;
<a name="l00383"></a>00383
<a name="l00384"></a>00384 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_STATS</span>
<a name="l00385"></a>00385 <span class="preprocessor"></span><span class="preprocessor">#define xntimer_init(timer, base, handler) \</span>
<a name="l00386"></a>00386 <span class="preprocessor"> do { \</span>
<a name="l00387"></a>00387 <span class="preprocessor"> __xntimer_init(timer, base, handler); \</span>
<a name="l00388"></a>00388 <span class="preprocessor"> (timer)->handler_name = #handler; \</span>
<a name="l00389"></a>00389 <span class="preprocessor"> } while (0)</span>
<a name="l00390"></a>00390 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* !CONFIG_XENO_OPT_STATS */</span>
<a name="l00391"></a>00391 <span class="preprocessor">#define xntimer_init __xntimer_init</span>
<a name="l00392"></a>00392 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* !CONFIG_XENO_OPT_STATS */</span>
<a name="l00393"></a>00393
<a name="l00394"></a>00394 <span class="preprocessor">#define xntimer_init_noblock(timer, base, handler) \</span>
<a name="l00395"></a>00395 <span class="preprocessor"> do { \</span>
<a name="l00396"></a>00396 <span class="preprocessor"> xntimer_init(timer, base, handler); \</span>
<a name="l00397"></a>00397 <span class="preprocessor"> (timer)->status |= XNTIMER_NOBLCK; \</span>
<a name="l00398"></a>00398 <span class="preprocessor"> } while(0)</span>
<a name="l00399"></a>00399 <span class="preprocessor"></span>
<a name="l00400"></a>00400 <span class="keywordtype">void</span> __xntimer_init(<span class="keyword">struct</span> xntimer *timer,
<a name="l00401"></a>00401 <span class="keyword">struct</span> xntbase *base,
<a name="l00402"></a>00402 <span class="keywordtype">void</span> (*handler)(<span class="keyword">struct</span> xntimer *timer));
<a name="l00403"></a>00403
<a name="l00404"></a>00404 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#g782e10b2cd24a5c303b316375940ca15" title="Release a timer object.">xntimer_destroy</a>(xntimer_t *timer);
<a name="l00405"></a>00405
<a name="l00406"></a>00406 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> xntimer_set_name(xntimer_t *timer, <span class="keyword">const</span> <span class="keywordtype">char</span> *name)
<a name="l00407"></a>00407 {
<a name="l00408"></a>00408 <span class="preprocessor">#ifdef CONFIG_XENO_OPT_STATS</span>
<a name="l00409"></a>00409 <span class="preprocessor"></span> strncpy(timer->name, name, <span class="keyword">sizeof</span>(timer->name));
<a name="l00410"></a>00410 <span class="preprocessor">#endif </span><span class="comment">/* CONFIG_XENO_OPT_STATS */</span>
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412
<a name="l00413"></a>00413 <span class="keywordtype">void</span> xntimer_next_local_shot(<span class="keyword">struct</span> <a class="code" href="structxnsched.html" title="Scheduling information structure.">xnsched</a> *sched);
<a name="l00414"></a>00414
<a name="l00419"></a>00419 <span class="preprocessor">#if defined(CONFIG_XENO_OPT_TIMING_PERIODIC) || defined(DOXYGEN_CPP)</span>
<a name="l00420"></a>00420 <span class="preprocessor"></span>
<a name="l00473"></a><a class="code" href="group__timer.html#g0ad3c70bed7fe1a45b45ee0875f031ab">00473</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__timer.html#g0ad3c70bed7fe1a45b45ee0875f031ab" title="Arm a timer.">xntimer_start</a>(xntimer_t *timer,
<a name="l00474"></a>00474 xnticks_t value, xnticks_t interval,
<a name="l00475"></a>00475 xntmode_t mode)
<a name="l00476"></a>00476 {
<a name="l00477"></a>00477 <span class="keywordflow">return</span> timer->base->ops->start_timer(timer, value, interval, mode);
<a name="l00478"></a>00478 }
<a name="l00479"></a>00479
<a name="l00505"></a><a class="code" href="group__timer.html#g1244411df9784d63d3e2f99016d62643">00505</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#g1244411df9784d63d3e2f99016d62643" title="Disarm a timer.">xntimer_stop</a>(xntimer_t *timer)
<a name="l00506"></a>00506 {
<a name="l00507"></a>00507 <span class="comment">/* Careful: the do_timer_stop() helper is expected to preserve</span>
<a name="l00508"></a>00508 <span class="comment"> the date field of the stopped timer, so that subsequent</span>
<a name="l00509"></a>00509 <span class="comment"> calls to xntimer_get_timeout() would still work on such</span>
<a name="l00510"></a>00510 <span class="comment"> timer as expected. */</span>
<a name="l00511"></a>00511 <span class="keywordflow">if</span> (!testbits(timer->status,XNTIMER_DEQUEUED))
<a name="l00512"></a>00512 timer->base->ops->stop_timer(timer);
<a name="l00513"></a>00513 }
<a name="l00514"></a>00514
<a name="l00547"></a><a class="code" href="group__timer.html#ge87b875cf9f6831afffcfee8dabd67a8">00547</a> <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t <a class="code" href="group__timer.html#ge87b875cf9f6831afffcfee8dabd67a8" title="Return the absolute expiration date.">xntimer_get_date</a>(xntimer_t *timer)
<a name="l00548"></a>00548 {
<a name="l00549"></a>00549 <span class="keywordflow">if</span> (!xntimer_running_p(timer))
<a name="l00550"></a>00550 <span class="keywordflow">return</span> XN_INFINITE;
<a name="l00551"></a>00551
<a name="l00552"></a>00552 <span class="keywordflow">return</span> timer->base->ops->get_timer_date(timer);
<a name="l00553"></a>00553 }
<a name="l00554"></a>00554
<a name="l00589"></a><a class="code" href="group__timer.html#g00d603a038b09e436717b84975b00abf">00589</a> <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t <a class="code" href="group__timer.html#g00d603a038b09e436717b84975b00abf" title="Return the relative expiration date.">xntimer_get_timeout</a>(xntimer_t *timer)
<a name="l00590"></a>00590 {
<a name="l00591"></a>00591 <span class="keywordflow">if</span> (!xntimer_running_p(timer))
<a name="l00592"></a>00592 <span class="keywordflow">return</span> XN_INFINITE;
<a name="l00593"></a>00593
<a name="l00594"></a>00594 <span class="keywordflow">return</span> timer->base->ops->get_timer_timeout(timer);
<a name="l00595"></a>00595 }
<a name="l00596"></a>00596
<a name="l00597"></a>00597 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t xntimer_get_timeout_stopped(xntimer_t *timer)
<a name="l00598"></a>00598 {
<a name="l00599"></a>00599 <span class="keywordflow">return</span> timer->base->ops->get_timer_timeout(timer);
<a name="l00600"></a>00600 }
<a name="l00601"></a>00601
<a name="l00633"></a><a class="code" href="group__timer.html#gb0d00a02bf04fdd48987d5d4efa68190">00633</a> <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t <a class="code" href="group__timer.html#gb0d00a02bf04fdd48987d5d4efa68190" title="Return the timer interval value.">xntimer_get_interval</a>(xntimer_t *timer)
<a name="l00634"></a>00634 {
<a name="l00635"></a>00635 <span class="keywordflow">return</span> timer->base->ops->get_timer_interval(timer);
<a name="l00636"></a>00636 }
<a name="l00637"></a>00637
<a name="l00638"></a>00638 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t xntimer_get_raw_expiry (xntimer_t *timer)
<a name="l00639"></a>00639 {
<a name="l00640"></a>00640 <span class="keywordflow">return</span> timer->base->ops->get_timer_raw_expiry(timer);
<a name="l00641"></a>00641 }
<a name="l00642"></a>00642
<a name="l00643"></a>00643 <span class="keywordtype">void</span> xntslave_init(xntslave_t *slave);
<a name="l00644"></a>00644
<a name="l00645"></a>00645 <span class="keywordtype">void</span> xntslave_destroy(xntslave_t *slave);
<a name="l00646"></a>00646
<a name="l00647"></a>00647 <span class="keywordtype">void</span> xntslave_update(xntslave_t *slave,
<a name="l00648"></a>00648 xnticks_t interval);
<a name="l00649"></a>00649
<a name="l00650"></a>00650 <span class="keywordtype">void</span> xntslave_start(xntslave_t *slave,
<a name="l00651"></a>00651 xnticks_t start,
<a name="l00652"></a>00652 xnticks_t interval);
<a name="l00653"></a>00653
<a name="l00654"></a>00654 <span class="keywordtype">void</span> xntslave_stop(xntslave_t *slave);
<a name="l00655"></a>00655
<a name="l00656"></a>00656 <span class="keywordtype">void</span> xntslave_adjust(xntslave_t *slave, xnsticks_t delta);
<a name="l00657"></a>00657
<a name="l00658"></a>00658 <span class="preprocessor">#else </span><span class="comment">/* !CONFIG_XENO_OPT_TIMING_PERIODIC */</span>
<a name="l00659"></a>00659
<a name="l00660"></a>00660 <span class="keywordtype">int</span> xntimer_start_aperiodic(xntimer_t *timer,
<a name="l00661"></a>00661 xnticks_t value,
<a name="l00662"></a>00662 xnticks_t interval,
<a name="l00663"></a>00663 xntmode_t mode);
<a name="l00664"></a>00664
<a name="l00665"></a>00665 <span class="keywordtype">void</span> xntimer_stop_aperiodic(xntimer_t *timer);
<a name="l00666"></a>00666
<a name="l00667"></a>00667 xnticks_t xntimer_get_date_aperiodic(xntimer_t *timer);
<a name="l00668"></a>00668
<a name="l00669"></a>00669 xnticks_t xntimer_get_timeout_aperiodic(xntimer_t *timer);
<a name="l00670"></a>00670
<a name="l00671"></a>00671 xnticks_t xntimer_get_interval_aperiodic(xntimer_t *timer);
<a name="l00672"></a>00672
<a name="l00673"></a>00673 xnticks_t xntimer_get_raw_expiry_aperiodic(xntimer_t *timer);
<a name="l00674"></a>00674
<a name="l00675"></a>00675 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group__timer.html#g0ad3c70bed7fe1a45b45ee0875f031ab" title="Arm a timer.">xntimer_start</a>(xntimer_t *timer,
<a name="l00676"></a>00676 xnticks_t value, xnticks_t interval,
<a name="l00677"></a>00677 xntmode_t mode)
<a name="l00678"></a>00678 {
<a name="l00679"></a>00679 <span class="keywordflow">return</span> xntimer_start_aperiodic(timer, value, interval, mode);
<a name="l00680"></a>00680 }
<a name="l00681"></a>00681
<a name="l00682"></a>00682 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group__timer.html#g1244411df9784d63d3e2f99016d62643" title="Disarm a timer.">xntimer_stop</a>(xntimer_t *timer)
<a name="l00683"></a>00683 {
<a name="l00684"></a>00684 <span class="keywordflow">if</span> (!testbits(timer->status,XNTIMER_DEQUEUED))
<a name="l00685"></a>00685 xntimer_stop_aperiodic(timer);
<a name="l00686"></a>00686 }
<a name="l00687"></a>00687
<a name="l00688"></a>00688 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t <a class="code" href="group__timer.html#ge87b875cf9f6831afffcfee8dabd67a8" title="Return the absolute expiration date.">xntimer_get_date</a>(xntimer_t *timer)
<a name="l00689"></a>00689 {
<a name="l00690"></a>00690 <span class="keywordflow">if</span> (!xntimer_running_p(timer))
<a name="l00691"></a>00691 <span class="keywordflow">return</span> XN_INFINITE;
<a name="l00692"></a>00692
<a name="l00693"></a>00693 <span class="keywordflow">return</span> xntimer_get_date_aperiodic(timer);
<a name="l00694"></a>00694 }
<a name="l00695"></a>00695
<a name="l00696"></a>00696 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t <a class="code" href="group__timer.html#g00d603a038b09e436717b84975b00abf" title="Return the relative expiration date.">xntimer_get_timeout</a>(xntimer_t *timer)
<a name="l00697"></a>00697 {
<a name="l00698"></a>00698 <span class="keywordflow">if</span> (!xntimer_running_p(timer))
<a name="l00699"></a>00699 <span class="keywordflow">return</span> XN_INFINITE;
<a name="l00700"></a>00700
<a name="l00701"></a>00701 <span class="keywordflow">return</span> xntimer_get_timeout_aperiodic(timer);
<a name="l00702"></a>00702 }
<a name="l00703"></a>00703
<a name="l00704"></a>00704 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t xntimer_get_timeout_stopped(xntimer_t *timer)
<a name="l00705"></a>00705 {
<a name="l00706"></a>00706 <span class="keywordflow">return</span> xntimer_get_timeout_aperiodic(timer);
<a name="l00707"></a>00707 }
<a name="l00708"></a>00708
<a name="l00709"></a>00709 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t <a class="code" href="group__timer.html#gb0d00a02bf04fdd48987d5d4efa68190" title="Return the timer interval value.">xntimer_get_interval</a>(xntimer_t *timer)
<a name="l00710"></a>00710 {
<a name="l00711"></a>00711 <span class="keywordflow">return</span> xntimer_get_interval_aperiodic(timer);
<a name="l00712"></a>00712 }
<a name="l00713"></a>00713
<a name="l00714"></a>00714 <span class="keyword">static</span> <span class="keyword">inline</span> xnticks_t xntimer_get_raw_expiry (xntimer_t *timer)
<a name="l00715"></a>00715 {
<a name="l00716"></a>00716 <span class="keywordflow">return</span> xntimerh_date(&timer->aplink);
<a name="l00717"></a>00717 }
<a name="l00718"></a>00718
<a name="l00719"></a>00719 <span class="preprocessor">#endif </span><span class="comment">/* CONFIG_XENO_OPT_TIMING_PERIODIC */</span>
<a name="l00720"></a>00720
<a name="l00723"></a>00723 <span class="keywordtype">void</span> xntimer_init_proc(<span class="keywordtype">void</span>);
<a name="l00724"></a>00724
<a name="l00725"></a>00725 <span class="keywordtype">void</span> xntimer_cleanup_proc(<span class="keywordtype">void</span>);
<a name="l00726"></a>00726
<a name="l00727"></a>00727 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="group__timer.html#g5609dd2602efe2c5b04eda28b22b9720" title="Get the count of overruns for the last tick.">xntimer_get_overruns</a>(xntimer_t *timer, xnticks_t now);
<a name="l00728"></a>00728
<a name="l00729"></a>00729 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#g5cad677279089ef19d3710b1b6452a71" title="Freeze all timers (from every time bases).">xntimer_freeze</a>(<span class="keywordtype">void</span>);
<a name="l00730"></a>00730
<a name="l00731"></a>00731 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#g26727f15ac845719913dcb703bf0c3fa" title="Process a timer tick for the aperiodic master time base.">xntimer_tick_aperiodic</a>(<span class="keywordtype">void</span>);
<a name="l00732"></a>00732
<a name="l00733"></a>00733 <span class="keywordtype">void</span> <a class="code" href="group__timer.html#g9b5391e752a8e16d89fb6a99c76bb7b1" title="Process a timer tick for a slave periodic time base.">xntimer_tick_periodic</a>(xntimer_t *timer);
<a name="l00734"></a>00734
<a name="l00735"></a>00735 <span class="keywordtype">void</span> xntimer_tick_periodic_inner(xntslave_t *slave);
<a name="l00736"></a>00736
<a name="l00737"></a>00737 <span class="keywordtype">void</span> xntimer_adjust_all_aperiodic(xnsticks_t delta);
<a name="l00738"></a>00738
<a name="l00739"></a>00739 <span class="preprocessor">#ifdef CONFIG_SMP</span>
<a name="l00740"></a>00740 <span class="preprocessor"></span><span class="keywordtype">int</span> xntimer_migrate(xntimer_t *timer,
<a name="l00741"></a>00741 <span class="keyword">struct</span> <a class="code" href="structxnsched.html" title="Scheduling information structure.">xnsched</a> *sched);
<a name="l00742"></a>00742 <span class="preprocessor">#else </span><span class="comment">/* ! CONFIG_SMP */</span>
<a name="l00743"></a>00743 <span class="preprocessor">#define xntimer_migrate(timer, sched) do { } while(0)</span>
<a name="l00744"></a>00744 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* CONFIG_SMP */</span>
<a name="l00745"></a>00745
<a name="l00746"></a>00746 <span class="preprocessor">#define xntimer_set_sched(timer, sched) xntimer_migrate(timer, sched)</span>
<a name="l00747"></a>00747 <span class="preprocessor"></span>
<a name="l00748"></a>00748 <span class="keywordtype">char</span> *xntimer_format_time(xnticks_t value, <span class="keywordtype">int</span> periodic,
<a name="l00749"></a>00749 <span class="keywordtype">char</span> *buf, <span class="keywordtype">size_t</span> bufsz);
<a name="l00750"></a>00750 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00751"></a>00751 <span class="preprocessor"></span>}
<a name="l00752"></a>00752 <span class="preprocessor">#endif</span>
<a name="l00753"></a>00753 <span class="preprocessor"></span>
<a name="l00754"></a>00754 <span class="preprocessor">#endif </span><span class="comment">/* __KERNEL__ || __XENO_SIM__ */</span>
<a name="l00755"></a>00755
<a name="l00756"></a>00756 <span class="preprocessor">#endif </span><span class="comment">/* !_XENO_NUCLEUS_TIMER_H */</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Aug 2 12:48:36 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>
|