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 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
|
<!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: Thread synchronization 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>Thread synchronization services.<br>
<small>
[<a class="el" href="group__nucleus.html">Xenomai nucleus.</a>]</small>
</h1>
<p>
<div class="dynheader">
Collaboration diagram for Thread synchronization services.:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__synch.png" border="0" alt="" usemap="#group____synch_map">
<map name="group____synch_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>
Thread synchronization services.
<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="synch_8c.html">synch.c</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Thread synchronization services. <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__synch.html#g4c07b8ec87b14cf18ef512f0e0aade51">xnsynch_init</a> (struct xnsynch *synch, xnflags_t flags, xnarch_atomic_t *fastlock)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Initialize a synchronization object. <a href="#g4c07b8ec87b14cf18ef512f0e0aade51"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">xnflags_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#g2747e9834546af461f118e7c90c9613e">xnsynch_sleep_on</a> (struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Sleep on an ownerless synchronization object. <a href="#g2747e9834546af461f118e7c90c9613e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct xnthread * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#gd5992ddbdb81821cb29bae8900eb65ac">xnsynch_wakeup_one_sleeper</a> (struct xnsynch *synch)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Give the resource ownership to the next waiting thread. <a href="#gd5992ddbdb81821cb29bae8900eb65ac"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct xnpholder * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#g9e530d12df9881251231af489208762e">xnsynch_wakeup_this_sleeper</a> (struct xnsynch *synch, struct xnpholder *holder)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Give the resource ownership to a given waiting thread. <a href="#g9e530d12df9881251231af489208762e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">xnflags_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#g6d4ad886901c751a4f3c51b90fc8f91f">xnsynch_acquire</a> (struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Acquire the ownership of a synchronization object. <a href="#g6d4ad886901c751a4f3c51b90fc8f91f"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#g268adcf6898492eb6ff82445899d4bc8">xnsynch_clear_boost</a> (struct xnsynch *synch, struct xnthread *owner)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Clear the priority boost. <a href="#g268adcf6898492eb6ff82445899d4bc8"></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__synch.html#g49c975f160509b1aa04df4900614b2ce">xnsynch_requeue_sleeper</a> (struct xnthread *thread)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Change a sleeper's priority. <a href="#g49c975f160509b1aa04df4900614b2ce"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct xnthread * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#g1208abb6b3d0017a4e0c43b9baff8cfb">xnsynch_release</a> (struct xnsynch *synch)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Give the resource ownership to the next waiting thread. <a href="#g1208abb6b3d0017a4e0c43b9baff8cfb"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct xnthread * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__synch.html#ge02c775ea161a0c27b919d019d170bc2">xnsynch_peek_pendq</a> (struct xnsynch *synch)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Access the thread leading a synch object wait queue. <a href="#ge02c775ea161a0c27b919d019d170bc2"></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__synch.html#g82beb68147bc5f0306ab02a61a9dc76b">xnsynch_flush</a> (struct xnsynch *synch, xnflags_t reason)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Unblock all waiters pending on a resource. <a href="#g82beb68147bc5f0306ab02a61a9dc76b"></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__synch.html#g997e546948920193bb36ab8d120fbab7">xnsynch_forget_sleeper</a> (struct xnthread *thread)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Abort a wait for a resource. <a href="#g997e546948920193bb36ab8d120fbab7"></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__synch.html#g51146a2d5bd0ec6a10d2fcd685946938">xnsynch_release_all_ownerships</a> (struct xnthread *thread)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Release all ownerships. <a href="#g51146a2d5bd0ec6a10d2fcd685946938"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g6d4ad886901c751a4f3c51b90fc8f91f"></a><!-- doxytag: member="synch.c::xnsynch_acquire" ref="g6d4ad886901c751a4f3c51b90fc8f91f" args="(struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">xnflags_t xnsynch_acquire </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</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>
Acquire the ownership of a synchronization object.
<p>
This service should be called by upper interfaces wanting the current thread to acquire the ownership of the given resource. If the resource is already assigned to a thread, the caller is suspended.<p>
This service must be used only with synchronization objects that track ownership (XNSYNCH_OWNER set.<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>synch</em> </td><td>The descriptor address of the synchronization object to acquire.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The timeout which may be used to limit the time the thread pends on the resource. This value is a wait time given in ticks (see note). It can either be relative, absolute monotonic, or absolute adjustable depending on <em>timeout_mode</em>. Passing XN_INFINITE <b>and</b> setting <em>mode</em> to XN_RELATIVE specifies an unbounded wait. All other values are used to initialize a watchdog timer.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout_mode</em> </td><td>The mode of the <em>timeout</em> parameter. It can either be set to XN_RELATIVE, XN_ABSOLUTE, or XN_REALTIME (see also <a class="el" href="group__timer.html#g0ad3c70bed7fe1a45b45ee0875f031ab" title="Arm a timer.">xntimer_start()</a>).</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A bitmask which may include zero or one information bit among XNRMID, XNTIMEO and XNBREAK, which should be tested by the caller, for detecting respectively: object deletion, timeout or signal/unblock conditions which might have happened while waiting.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: possible.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the current thread is bound to a periodic time base (see xnpod_init_thread), or nanoseconds otherwise. </dd></dl>
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00048">XNBOOST</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00110">XNBREAK</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, <a class="el" href="pod_8c-source.html#l01361">xnpod_suspend_thread()</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00109">XNRMID</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00113">XNROBBED</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00108">XNTIMEO</a>, and <a class="el" href="include_2nucleus_2thread_8h-source.html#l00112">XNWAKEN</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2posix_2mutex_8c-source.html#l00251">pthread_mutex_destroy()</a>, <a class="el" href="ksrc_2skins_2native_2task_8c-source.html#l01717">rt_task_send()</a>, and <a class="el" href="drvlib_8c-source.html#l01523">rtdm_mutex_timedlock()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g268adcf6898492eb6ff82445899d4bc8"></a><!-- doxytag: member="synch.c::xnsynch_clear_boost" ref="g268adcf6898492eb6ff82445899d4bc8" args="(struct xnsynch *synch, struct xnthread *owner)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnsynch_clear_boost </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct xnthread * </td>
<td class="paramname"> <em>owner</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [static]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Clear the priority boost.
<p>
<p><b>For internal use only.</b></p>
<p>
This service is called internally whenever a synchronization object is not claimed anymore by sleepers to reset the object owner's priority to its initial level.<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>synch</em> </td><td>The descriptor address of the synchronization object.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>owner</em> </td><td>The descriptor address of the thread which currently owns the synchronization object.</td></tr>
</table>
</dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This routine must be entered nklock locked, interrupts off. </dd></dl>
</p>
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00048">XNBOOST</a>.</p>
<p>Referenced by <a class="el" href="synch_8c-source.html#l00848">xnsynch_flush()</a>, <a class="el" href="synch_8c-source.html#l00900">xnsynch_forget_sleeper()</a>, and <a class="el" href="synch_8c-source.html#l00707">xnsynch_release()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g82beb68147bc5f0306ab02a61a9dc76b"></a><!-- doxytag: member="synch.c::xnsynch_flush" ref="g82beb68147bc5f0306ab02a61a9dc76b" args="(struct xnsynch *synch, xnflags_t reason)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int xnsynch_flush </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">xnflags_t </td>
<td class="paramname"> <em>reason</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Unblock all waiters pending on a resource.
<p>
This service atomically releases all threads which currently sleep on a given resource.<p>
This service should be called by upper interfaces under circumstances requiring that the pending queue of a given resource is cleared, such as before the resource is deleted.<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>synch</em> </td><td>The descriptor address of the synchronization object to be flushed.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>reason</em> </td><td>Some flags to set in the information mask of every unblocked thread. Zero is an acceptable value. The following bits are pre-defined by the nucleus:</td></tr>
</table>
</dl>
<ul>
<li>XNRMID should be set to indicate that the synchronization object is about to be destroyed (see <a class="el" href="group__pod.html#gc3a7bf9e973782a8cfd6495a1786e812" title="Resume a thread.">xnpod_resume_thread()</a>).</li></ul>
<p>
<ul>
<li>XNBREAK should be set to indicate that the wait has been forcibly interrupted (see <a class="el" href="group__pod.html#ge5f0d19e7a499b9b262f68a43ab545dd" title="Unblock a thread.">xnpod_unblock_thread()</a>).</li></ul>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>XNSYNCH_RESCHED is returned if at least one thread is unblocked, which means the caller should invoke <a class="el" href="group__pod.html#gcf5b53f0405351327b89b0cc4976b962" title="Rescheduling procedure entry point.">xnpod_schedule()</a> for applying the new scheduling state. Otherwise, XNSYNCH_DONE is returned.</dd></dl>
Side-effects:<p>
<ul>
<li>The effective priority of the previous resource owner might be lowered to its base priority value as a consequence of the priority inheritance boost being cleared.</li></ul>
<p>
<ul>
<li>The synchronization object is no more owned by any thread.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: never.
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, <a class="el" href="pod_8c-source.html#l01575">xnpod_resume_thread()</a>, and <a class="el" href="synch_8c-source.html#l00577">xnsynch_clear_boost()</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2posix_2cond_8c-source.html#l00576">pthread_cond_broadcast()</a>, <a class="el" href="skins_2posix_2thread_8c-source.html#l00302">pthread_detach()</a>, <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l01043">rt_buffer_clear()</a>, <a class="el" href="ksrc_2skins_2native_2cond_8c-source.html#l00351">rt_cond_broadcast()</a>, <a class="el" href="ksrc_2skins_2native_2sem_8c-source.html#l00541">rt_sem_broadcast()</a>, <a class="el" href="ksrc_2skins_2native_2task_8c-source.html#l01717">rt_task_send()</a>, <a class="el" href="drvlib_8c-source.html#l00850">rtdm_event_signal()</a>, and <a class="el" href="nucleus_2registry_8c-source.html#l01084">xnregistry_put()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g997e546948920193bb36ab8d120fbab7"></a><!-- doxytag: member="synch.c::xnsynch_forget_sleeper" ref="g997e546948920193bb36ab8d120fbab7" args="(struct xnthread *thread)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnsynch_forget_sleeper </td>
<td>(</td>
<td class="paramtype">struct xnthread * </td>
<td class="paramname"> <em>thread</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Abort a wait for a resource.
<p>
<p><b>For internal use only.</b></p>
<p>
Performs all the necessary housekeeping chores to stop a thread from waiting on a given synchronization object.<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>thread</em> </td><td>The descriptor address of the affected thread.</td></tr>
</table>
</dl>
When the trace support is enabled (i.e. MVM), the idle state is posted to the synchronization object's state diagram (if any) whenever no thread remains blocked on it. The real-time interfaces must ensure that such condition (i.e. EMPTY/IDLE) is mapped to state #0.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This routine must be entered nklock locked, interrupts off. </dd></dl>
</p>
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, and <a class="el" href="synch_8c-source.html#l00577">xnsynch_clear_boost()</a>.</p>
<p>Referenced by <a class="el" href="pod_8c-source.html#l01078">xnpod_delete_thread()</a>, <a class="el" href="pod_8c-source.html#l01575">xnpod_resume_thread()</a>, and <a class="el" href="pod_8c-source.html#l01361">xnpod_suspend_thread()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g4c07b8ec87b14cf18ef512f0e0aade51"></a><!-- doxytag: member="synch.c::xnsynch_init" ref="g4c07b8ec87b14cf18ef512f0e0aade51" args="(struct xnsynch *synch, xnflags_t flags, xnarch_atomic_t *fastlock)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnsynch_init </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">xnflags_t </td>
<td class="paramname"> <em>flags</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">xnarch_atomic_t * </td>
<td class="paramname"> <em>fastlock</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Initialize a synchronization object.
<p>
Initializes a new specialized object which can subsequently be used to synchronize real-time activities. The Xenomai nucleus provides a basic synchronization object which can be used to build higher resource objects. Nucleus threads can wait for and signal such objects in order to synchronize their activities.<p>
This object has built-in support for priority inheritance.<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>synch</em> </td><td>The address of a synchronization object descriptor the nucleus will use to store the object-specific data. This descriptor must always be valid while the object is active therefore it must be allocated in permanent memory.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>flags</em> </td><td>A set of creation flags affecting the operation. The valid flags are:</td></tr>
</table>
</dl>
<ul>
<li>XNSYNCH_PRIO causes the threads waiting for the resource to pend in priority order. Otherwise, FIFO ordering is used (XNSYNCH_FIFO).</li></ul>
<p>
<ul>
<li>XNSYNCH_OWNER indicates that the synchronization object shall track its owning thread (required if XNSYNCH_PIP is selected). Note that setting this flag implies the use xnsynch_acquire and xnsynch_release instead of xnsynch_sleep_on and xnsynch_wakeup_one_sleeper/xnsynch_wakeup_this_sleeper.</li></ul>
<p>
<ul>
<li>XNSYNCH_PIP causes the priority inheritance mechanism to be automatically activated when a priority inversion is detected among threads using this object. Otherwise, no priority inheritance takes place upon priority inversion (XNSYNCH_NOPIP).</li></ul>
<p>
<ul>
<li>XNSYNCH_DREORD (Disable REORDering) tells the nucleus that the wait queue should not be reordered whenever the priority of a blocked thread it holds is changed. If this flag is not specified, changing the priority of a blocked thread using <a class="el" href="group__pod.html#g6d535ef9821e98fd7f257b50a3c8d595" title="Change the base scheduling parameters of a thread.">xnpod_set_thread_schedparam()</a> will cause this object's wait queue to be reordered according to the new priority level, provided the synchronization object makes the waiters wait by priority order on the awaited resource (XNSYNCH_PRIO).</li></ul>
<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>fastlock</em> </td><td>Address of the fast lock word to be associated with the synchronization object. If NULL is passed or XNSYNCH_OWNER is not set, fast-lock support is disabled.</td></tr>
</table>
</dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: never.
<p>Referenced by <a class="el" href="ksrc_2skins_2posix_2cond_8c-source.html#l00106">pthread_cond_init()</a>, <a class="el" href="skins_2posix_2thread_8c-source.html#l00165">pthread_create()</a>, <a class="el" href="ksrc_2skins_2posix_2intr_8c-source.html#l00102">pthread_intr_attach_np()</a>, <a class="el" href="ksrc_2skins_2native_2alarm_8c-source.html#l00187">rt_alarm_create()</a>, <a class="el" href="ksrc_2skins_2native_2buffer_8c-source.html#l00191">rt_buffer_create()</a>, <a class="el" href="ksrc_2skins_2native_2cond_8c-source.html#l00155">rt_cond_create()</a>, <a class="el" href="ksrc_2skins_2native_2event_8c-source.html#l00177">rt_event_create()</a>, <a class="el" href="ksrc_2skins_2native_2heap_8c-source.html#l00241">rt_heap_create()</a>, <a class="el" href="ksrc_2skins_2native_2intr_8c-source.html#l00250">rt_intr_create()</a>, <a class="el" href="ksrc_2skins_2native_2queue_8c-source.html#l00209">rt_queue_create()</a>, <a class="el" href="ksrc_2skins_2native_2sem_8c-source.html#l00173">rt_sem_create()</a>, <a class="el" href="ksrc_2skins_2native_2task_8c-source.html#l00249">rt_task_create()</a>, <a class="el" href="drvlib_8c-source.html#l00769">rtdm_event_init()</a>, <a class="el" href="drvlib_8c-source.html#l01405">rtdm_mutex_init()</a>, <a class="el" href="drvlib_8c-source.html#l01120">rtdm_sem_init()</a>, <a class="el" href="nucleus_2registry_8c-source.html#l00573">xnregistry_enter()</a>, and <a class="el" href="select_8c-source.html#l00285">xnselector_init()</a>.</p>
</div>
</div><p>
<a class="anchor" name="ge02c775ea161a0c27b919d019d170bc2"></a><!-- doxytag: member="synch.c::xnsynch_peek_pendq" ref="ge02c775ea161a0c27b919d019d170bc2" args="(struct xnsynch *synch)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct xnthread* xnsynch_peek_pendq </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em> </td>
<td> ) </td>
<td><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Access the thread leading a synch object wait queue.
<p>
This services returns the descriptor address of to the thread leading a synchronization object wait queue.<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>synch</em> </td><td>The descriptor address of the target synchronization object.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The descriptor address of the unblocked thread.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: never.
</div>
</div><p>
<a class="anchor" name="g1208abb6b3d0017a4e0c43b9baff8cfb"></a><!-- doxytag: member="synch.c::xnsynch_release" ref="g1208abb6b3d0017a4e0c43b9baff8cfb" args="(struct xnsynch *synch)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct xnthread* xnsynch_release </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em> </td>
<td> ) </td>
<td><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Give the resource ownership to the next waiting thread.
<p>
This service releases the ownership of the given synchronization object. The thread which is currently leading the object's pending list, if any, is unblocked from its pending state. However, no reschedule is performed.<p>
This service must be used only with synchronization objects that track ownership (XNSYNCH_OWNER set).<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>synch</em> </td><td>The descriptor address of the synchronization object whose ownership is changed.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The descriptor address of the unblocked thread.</dd></dl>
Side-effects:<p>
<ul>
<li>The effective priority of the previous resource owner might be lowered to its base priority value as a consequence of the priority inheritance boost being cleared.</li></ul>
<p>
<ul>
<li>The synchronization object ownership is transfered to the unblocked thread.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: never.
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, <a class="el" href="pod_8c-source.html#l01575">xnpod_resume_thread()</a>, <a class="el" href="synch_8c-source.html#l00577">xnsynch_clear_boost()</a>, and <a class="el" href="include_2nucleus_2thread_8h-source.html#l00112">XNWAKEN</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2posix_2mutex_8c-source.html#l00590">pthread_mutex_unlock()</a>, <a class="el" href="ksrc_2skins_2native_2mutex_8c-source.html#l00563">rt_mutex_release()</a>, and <a class="el" href="synch_8c-source.html#l00960">xnsynch_release_all_ownerships()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g51146a2d5bd0ec6a10d2fcd685946938"></a><!-- doxytag: member="synch.c::xnsynch_release_all_ownerships" ref="g51146a2d5bd0ec6a10d2fcd685946938" args="(struct xnthread *thread)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnsynch_release_all_ownerships </td>
<td>(</td>
<td class="paramtype">struct xnthread * </td>
<td class="paramname"> <em>thread</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Release all ownerships.
<p>
<p><b>For internal use only.</b></p>
<p>
This call is used internally to release all the ownerships obtained by a thread on synchronization objects. This routine must be entered interrupts off.<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>thread</em> </td><td>The descriptor address of the affected thread.</td></tr>
</table>
</dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This routine must be entered nklock locked, interrupts off. </dd></dl>
</p>
<p>References <a class="el" href="synch_8c-source.html#l00707">xnsynch_release()</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="g49c975f160509b1aa04df4900614b2ce"></a><!-- doxytag: member="synch.c::xnsynch_requeue_sleeper" ref="g49c975f160509b1aa04df4900614b2ce" args="(struct xnthread *thread)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void xnsynch_requeue_sleeper </td>
<td>(</td>
<td class="paramtype">struct xnthread * </td>
<td class="paramname"> <em>thread</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Change a sleeper's priority.
<p>
<p><b>For internal use only.</b></p>
<p>
This service is used by the PIP code to update the pending priority of a sleeping thread.<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>thread</em> </td><td>The descriptor address of the affected thread.</td></tr>
</table>
</dl>
<dl class="note" compact><dt><b>Note:</b></dt><dd>This routine must be entered nklock locked, interrupts off. </dd></dl>
</p>
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00048">XNBOOST</a>.</p>
</div>
</div><p>
<a class="anchor" name="g2747e9834546af461f118e7c90c9613e"></a><!-- doxytag: member="synch.c::xnsynch_sleep_on" ref="g2747e9834546af461f118e7c90c9613e" args="(struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">xnflags_t xnsynch_sleep_on </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</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>
Sleep on an ownerless synchronization object.
<p>
Makes the calling thread sleep on the specified synchronization object, waiting for it to be signaled.<p>
This service should be called by upper interfaces wanting the current thread to pend on the given resource. It must not be used with synchronization objects that are supposed to track ownership (XNSYNCH_OWNER).<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>synch</em> </td><td>The descriptor address of the synchronization object to sleep on.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The timeout which may be used to limit the time the thread pends on the resource. This value is a wait time given in ticks (see note). It can either be relative, absolute monotonic, or absolute adjustable depending on <em>timeout_mode</em>. Passing XN_INFINITE <b>and</b> setting <em>mode</em> to XN_RELATIVE specifies an unbounded wait. All other values are used to initialize a watchdog timer.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout_mode</em> </td><td>The mode of the <em>timeout</em> parameter. It can either be set to XN_RELATIVE, XN_ABSOLUTE, or XN_REALTIME (see also <a class="el" href="group__timer.html#g0ad3c70bed7fe1a45b45ee0875f031ab" title="Arm a timer.">xntimer_start()</a>).</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A bitmask which may include zero or one information bit among XNRMID, XNTIMEO and XNBREAK, which should be tested by the caller, for detecting respectively: object deletion, timeout or signal/unblock conditions which might have happened while waiting.</dd></dl>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: always.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the current thread is bound to a periodic time base (see xnpod_init_thread), or nanoseconds otherwise. </dd></dl>
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00110">XNBREAK</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, <a class="el" href="pod_8c-source.html#l01361">xnpod_suspend_thread()</a>, <a class="el" href="include_2nucleus_2thread_8h-source.html#l00109">XNRMID</a>, and <a class="el" href="include_2nucleus_2thread_8h-source.html#l00108">XNTIMEO</a>.</p>
<p>Referenced by <a class="el" href="skins_2posix_2thread_8c-source.html#l00430">pthread_join()</a>, <a class="el" href="ksrc_2skins_2native_2heap_8c-source.html#l00512">rt_heap_alloc()</a>, <a class="el" href="ksrc_2skins_2native_2task_8c-source.html#l01913">rt_task_receive()</a>, <a class="el" href="drvlib_8c-source.html#l00944">rtdm_event_timedwait()</a>, <a class="el" href="drvlib_8c-source.html#l01229">rtdm_sem_timeddown()</a>, <a class="el" href="nucleus_2registry_8c-source.html#l00715">xnregistry_bind()</a>, <a class="el" href="nucleus_2registry_8c-source.html#l00916">xnregistry_remove_safe()</a>, and <a class="el" href="select_8c-source.html#l00322">xnselect()</a>.</p>
</div>
</div><p>
<a class="anchor" name="gd5992ddbdb81821cb29bae8900eb65ac"></a><!-- doxytag: member="synch.c::xnsynch_wakeup_one_sleeper" ref="gd5992ddbdb81821cb29bae8900eb65ac" args="(struct xnsynch *synch)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct xnthread* xnsynch_wakeup_one_sleeper </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em> </td>
<td> ) </td>
<td><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Give the resource ownership to the next waiting thread.
<p>
This service wakes up the thread which is currently leading the synchronization object's pending list. The sleeping thread is unblocked from its pending state, but no reschedule is performed.<p>
This service should be called by upper interfaces wanting to signal the given resource so that a single waiter is resumed. It must not be used with synchronization objects that are supposed to track ownership (XNSYNCH_OWNER not set).<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>synch</em> </td><td>The descriptor address of the synchronization object whose ownership is changed.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The descriptor address of the unblocked thread.</dd></dl>
Side-effects:<p>
<ul>
<li>The effective priority of the previous resource owner might be lowered to its base priority value as a consequence of the priority inheritance boost being cleared.</li></ul>
<p>
<ul>
<li>The synchronization object ownership is transfered to the unblocked thread.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: never.
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, and <a class="el" href="pod_8c-source.html#l01575">xnpod_resume_thread()</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2posix_2cond_8c-source.html#l00526">pthread_cond_signal()</a>, <a class="el" href="skins_2posix_2thread_8c-source.html#l00430">pthread_join()</a>, <a class="el" href="ksrc_2skins_2native_2cond_8c-source.html#l00295">rt_cond_signal()</a>, <a class="el" href="ksrc_2skins_2native_2queue_8c-source.html#l00595">rt_queue_send()</a>, <a class="el" href="ksrc_2skins_2native_2sem_8c-source.html#l00487">rt_sem_v()</a>, <a class="el" href="drvlib_8c-source.html#l01302">rtdm_sem_up()</a>, and <a class="el" href="ksrc_2skins_2posix_2sem_8c-source.html#l00716">sem_post()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g9e530d12df9881251231af489208762e"></a><!-- doxytag: member="synch.c::xnsynch_wakeup_this_sleeper" ref="g9e530d12df9881251231af489208762e" args="(struct xnsynch *synch, struct xnpholder *holder)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct xnpholder* xnsynch_wakeup_this_sleeper </td>
<td>(</td>
<td class="paramtype">struct xnsynch * </td>
<td class="paramname"> <em>synch</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct xnpholder * </td>
<td class="paramname"> <em>holder</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Give the resource ownership to a given waiting thread.
<p>
This service wakes up a specific thread which is currently pending on the given synchronization object. The sleeping thread is unblocked from its pending state, but no reschedule is performed.<p>
This service should be called by upper interfaces wanting to signal the given resource so that a specific waiter is resumed. It must not be used with synchronization objects that are supposed to track ownership (XNSYNCH_OWNER not set).<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>synch</em> </td><td>The descriptor address of the synchronization object whose ownership is changed.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>holder</em> </td><td>The link holder address of the thread to unblock (&thread->plink) which MUST be currently linked to the synchronization object's pending queue (i.e. synch->pendq).</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The link address of the unblocked thread in the synchronization object's pending queue.</dd></dl>
Side-effects:<p>
<ul>
<li>The effective priority of the previous resource owner might be lowered to its base priority value as a consequence of the priority inheritance boost being cleared.</li></ul>
<p>
<ul>
<li>The synchronization object ownership is transfered to the unblocked thread.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine</li><li>Kernel-based task</li><li>User-space task</li></ul>
<p>
Rescheduling: never.
<p>References <a class="el" href="include_2nucleus_2thread_8h-source.html#l00036">XNPEND</a>, and <a class="el" href="pod_8c-source.html#l01575">xnpod_resume_thread()</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2event_8c-source.html#l00315">rt_event_signal()</a>, and <a class="el" href="ksrc_2skins_2native_2heap_8c-source.html#l00631">rt_heap_free()</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>
|