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 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026
|
<!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: Message queue 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>Message queue services.<br>
<small>
[<a class="el" href="group__native.html">Native Xenomai API.</a>]</small>
</h1>
<p>
<div class="dynheader">
Collaboration diagram for Message queue services.:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__native__queue.png" border="0" alt="" usemap="#group____native____queue_map">
<map name="group____native____queue_map">
<area shape="rect" href="group__native.html" title="Native Xenomai API." alt="" coords="5,5,157,32"></map></td></tr></table></center>
</div>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Queue services.<p>
Message queueing is a method by which real-time tasks can exchange or pass data through a Xenomai-managed queue of messages. Messages can vary in length and be assigned different types or usages. A message queue can be created by one task and used by multiple tasks that send and/or receive messages to the queue.<p>
This implementation is based on a zero-copy scheme for message buffers. Message buffer pools are built over the nucleus's heap objects, which in turn provide the needed support for exchanging messages between kernel and user-space using direct memory mapping.
<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="ksrc_2skins_2native_2queue_8c.html">queue.c</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">This file is part of the Xenomai project. <br></td></tr>
<p>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__native__queue.html#gacad717bbd6d75338fada8f5b4a67b3f">rt_queue_create</a> (RT_QUEUE *q, const char *name, size_t poolsize, size_t qlimit, int mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Create a message queue. <a href="#gacad717bbd6d75338fada8f5b4a67b3f"></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__native__queue.html#gbc678dfb236b0dad434067496cead127">rt_queue_delete</a> (RT_QUEUE *q)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Delete a message queue. <a href="#gbc678dfb236b0dad434067496cead127"></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__native__queue.html#g8eaee8ca7d0c3af801c4df6f0adae421">rt_queue_alloc</a> (RT_QUEUE *q, size_t size)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Allocate a message queue buffer. <a href="#g8eaee8ca7d0c3af801c4df6f0adae421"></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__native__queue.html#g40d16a5ab14ea033889bb839967204e4">rt_queue_free</a> (RT_QUEUE *q, void *buf)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Free a message queue buffer. <a href="#g40d16a5ab14ea033889bb839967204e4"></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__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d">rt_queue_send</a> (RT_QUEUE *q, void *mbuf, size_t size, int mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Send a message to a queue. <a href="#g8b1dcb15753bdfce02f25f166e18948d"></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__native__queue.html#g9ef8d1826bb13fe706a4566890972657">rt_queue_write</a> (RT_QUEUE *q, const void *buf, size_t size, int mode)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Write a message to a queue. <a href="#g9ef8d1826bb13fe706a4566890972657"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__native__queue.html#g44759168a589ddbb2b60c1c1b183f448">rt_queue_receive</a> (RT_QUEUE *q, void **bufp, RTIME timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Receive a message from a queue. <a href="#g44759168a589ddbb2b60c1c1b183f448"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__native__queue.html#gde7b66ff83b602b6265cb1cb768c18db">rt_queue_receive_until</a> (RT_QUEUE *q, void **bufp, RTIME timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Receive a message from a queue (with absolute timeout date). <a href="#gde7b66ff83b602b6265cb1cb768c18db"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__native__queue.html#g4083beec0186ce66c66ee0d3fc1b5eee">rt_queue_read</a> (RT_QUEUE *q, void *buf, size_t size, RTIME timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Read a message from a queue. <a href="#g4083beec0186ce66c66ee0d3fc1b5eee"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">ssize_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__native__queue.html#g91dca49cc0fd0b30b8fe66eb6bc7ea8a">rt_queue_read_until</a> (RT_QUEUE *q, void *buf, size_t size, RTIME timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Read a message from a queue (with absolute timeout date). <a href="#g91dca49cc0fd0b30b8fe66eb6bc7ea8a"></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__native__queue.html#gffac609e575d3dc57392cc84b743e504">rt_queue_flush</a> (RT_QUEUE *q)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Flush a message queue. <a href="#gffac609e575d3dc57392cc84b743e504"></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__native__queue.html#g654017c0f87d8c23329aeefff93e6a70">rt_queue_inquire</a> (RT_QUEUE *q, RT_QUEUE_INFO *info)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Inquire about a message queue. <a href="#g654017c0f87d8c23329aeefff93e6a70"></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__native__queue.html#g162bb372c5c3616666e8e1fbdcc79343">rt_queue_bind</a> (RT_QUEUE *q, const char *name, RTIME timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Bind to a shared message queue. <a href="#g162bb372c5c3616666e8e1fbdcc79343"></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__native__queue.html#g1f190858ca18d906db339e086bfa8ced">rt_queue_unbind</a> (RT_QUEUE *q)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Unbind from a shared message queue. <a href="#g1f190858ca18d906db339e086bfa8ced"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g8eaee8ca7d0c3af801c4df6f0adae421"></a><!-- doxytag: member="queue.c::rt_queue_alloc" ref="g8eaee8ca7d0c3af801c4df6f0adae421" args="(RT_QUEUE *q, size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* rt_queue_alloc </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a message queue buffer.
<p>
This service allocates a message buffer from the queue's internal pool which can be subsequently filled by the caller then passed to <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a> for sending.<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>q</em> </td><td>The descriptor address of the affected queue.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The requested size in bytes of the buffer. Zero is an acceptable value, meaning that the message will not carry any payload data; the receiver will thus receive a zero-sized message.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The address of the allocated message buffer upon success, or NULL if the allocation fails.</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.
<p>References <a class="el" href="ksrc_2nucleus_2heap_8c-source.html#l00481">xnheap_alloc()</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2queue_8c-source.html#l00727">rt_queue_write()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g162bb372c5c3616666e8e1fbdcc79343"></a><!-- doxytag: member="queue.c::rt_queue_bind" ref="g162bb372c5c3616666e8e1fbdcc79343" args="(RT_QUEUE *q, const char *name, RTIME timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_bind </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">RTIME </td>
<td class="paramname"> <em>timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Bind to a shared message queue.
<p>
This user-space only service retrieves the uniform descriptor of a given shared Xenomai message queue identified by its symbolic name. If the queue does not exist on entry, this service blocks the caller until a queue of the given name is created.<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>name</em> </td><td>A valid NULL-terminated name which identifies the queue to bind to.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>q</em> </td><td>The address of a queue descriptor retrieved by the operation. Contents of this memory is undefined upon failure.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The number of clock ticks to wait for the registration to occur (see note). Passing TM_INFINITE causes the caller to block indefinitely until the object is registered. Passing TM_NONBLOCK causes the service to return immediately without waiting if the object is not registered on entry.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 is returned upon success. Otherwise:</dd></dl>
<ul>
<li>-EFAULT is returned if <em>q</em> or <em>name</em> is referencing invalid memory.</li></ul>
<p>
<ul>
<li>-EINTR is returned if <a class="el" href="group__task.html#g770281eeca009c0a08a7c4a9fd849ac1" title="Unblock a real-time task.">rt_task_unblock()</a> has been called for the waiting task before the retrieval has completed.</li></ul>
<p>
<ul>
<li>-EWOULDBLOCK is returned if <em>timeout</em> is equal to TM_NONBLOCK and the searched object is not registered on entry.</li></ul>
<p>
<ul>
<li>-ETIMEDOUT is returned if the object cannot be retrieved within the specified amount of time.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service should block, but was called from a context which cannot sleep (e.g. interrupt, non-realtime context). This error may also be returned whenever the call attempts to bind from a user-space application to a local queue defined from kernel space (i.e. Q_SHARED was not passed to <a class="el" href="group__native__queue.html#gacad717bbd6d75338fada8f5b4a67b3f" title="Create a message queue.">rt_queue_create()</a>).</li></ul>
<p>
<ul>
<li>-ENOENT is returned if the special file /dev/rtheap (character-mode, major 10, minor 254) is not available from the filesystem. This device is needed to map the memory pool used by the shared queue into the caller's address space. udev-based systems should not need manual creation of such device entry.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>User-space task (switches to primary mode)</li></ul>
<p>
Rescheduling: always unless the request is immediately satisfied or <em>timeout</em> specifies a non-blocking operation.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the native skin is bound to a periodic time base (see CONFIG_XENO_OPT_NATIVE_PERIOD), or nanoseconds otherwise. </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="msg__queue_8c-example.html#a0">msg_queue.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="gacad717bbd6d75338fada8f5b4a67b3f"></a><!-- doxytag: member="queue.c::rt_queue_create" ref="gacad717bbd6d75338fada8f5b4a67b3f" args="(RT_QUEUE *q, const char *name, size_t poolsize, size_t qlimit, int mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_create </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>poolsize</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>qlimit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>mode</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a message queue.
<p>
Create a message queue object that allows multiple tasks to exchange data through the use of variable-sized messages. A message queue is created empty. Message queues can be local to the kernel space, or shared between kernel and user-space.<p>
This service needs the special character device /dev/rtheap (10,254) when called from user-space tasks.<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>q</em> </td><td>The address of a queue descriptor Xenomai will use to store the queue-related data. This descriptor must always be valid while the message queue is active therefore it must be allocated in permanent memory.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>name</em> </td><td>An ASCII string standing for the symbolic name of the queue. When non-NULL and non-empty, this string is copied to a safe place into the descriptor, and passed to the registry package if enabled for indexing the created queue. Shared queues must be given a valid name.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>poolsize</em> </td><td>The size (in bytes) of the message buffer pool which is going to be pre-allocated to the queue. Message buffers will be claimed and released to this pool. The buffer pool memory is not extensible, so this value must be compatible with the highest message pressure that could be expected.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>qlimit</em> </td><td>This parameter allows to limit the maximum number of messages which can be queued at any point in time. Sending to a full queue begets an error. The special value Q_UNLIMITED can be passed to specify an unlimited amount.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>mode</em> </td><td>The queue creation mode. The following flags can be OR'ed into this bitmask, each of them affecting the new queue:</td></tr>
</table>
</dl>
<ul>
<li>Q_FIFO makes tasks pend in FIFO order on the queue for consuming messages.</li></ul>
<p>
<ul>
<li>Q_PRIO makes tasks pend in priority order on the queue.</li></ul>
<p>
<ul>
<li>Q_SHARED causes the queue to be sharable between kernel and user-space tasks. Otherwise, the new queue is only available for kernel-based usage. This flag is implicitely set when the caller is running in user-space. This feature requires the real-time support in user-space to be configured in (CONFIG_XENO_OPT_PERVASIVE).</li></ul>
<p>
<ul>
<li>Q_DMA causes the buffer pool associated to the queue to be allocated in physically contiguous memory, suitable for DMA operations with I/O devices. A 128Kb limit exists for <em>poolsize</em> when this flag is passed.</li></ul>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 is returned upon success. Otherwise:</dd></dl>
<ul>
<li>-EEXIST is returned if the <em>name</em> is already in use by some registered object.</li></ul>
<p>
<ul>
<li>-EINVAL is returned if <em>poolsize</em> is null, greater than the system limit, or <em>name</em> is null or empty for a shared queue.</li></ul>
<p>
<ul>
<li>-ENOMEM is returned if not enough system memory is available to create or register the queue. Additionally, and if Q_SHARED has been passed in <em>mode</em>, errors while mapping the buffer pool in the caller's address space might beget this return code too.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service was called from an invalid context.</li></ul>
<p>
<ul>
<li>-ENOSYS is returned if <em>mode</em> specifies Q_SHARED, but the real-time support in user-space is unavailable.</li></ul>
<p>
<ul>
<li>-ENOENT is returned if /dev/rtheap can't be opened.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>User-space task (switches to secondary mode)</li></ul>
<p>
Rescheduling: possible.
<p>References <a class="el" href="src_2skins_2native_2queue_8c-source.html#l00096">rt_queue_delete()</a>, <a class="el" href="ksrc_2nucleus_2heap_8c-source.html#l00167">xnheap_init()</a>, <a class="el" href="ksrc_2nucleus_2heap_8c-source.html#l00276">xnheap_set_label()</a>, <a class="el" href="nucleus_2registry_8c-source.html#l00573">xnregistry_enter()</a>, and <a class="el" href="synch_8c-source.html#l00102">xnsynch_init()</a>.</p>
</div>
</div><p>
<a class="anchor" name="gbc678dfb236b0dad434067496cead127"></a><!-- doxytag: member="queue.c::rt_queue_delete" ref="gbc678dfb236b0dad434067496cead127" args="(RT_QUEUE *q)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_delete </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Delete a message queue.
<p>
Destroy a message queue and release all the tasks currently pending on it. A queue exists in the system since <a class="el" href="group__native__queue.html#gacad717bbd6d75338fada8f5b4a67b3f" title="Create a message queue.">rt_queue_create()</a> has been called to create it, so this service must be called in order to destroy it afterwards.<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>q</em> </td><td>The descriptor address of the affected queue.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 is returned upon success. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service was called from an asynchronous context.</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>User-space task (switches to secondary mode).</li></ul>
<p>
Rescheduling: possible.
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2queue_8c-source.html#l00209">rt_queue_create()</a>.</p>
</div>
</div><p>
<a class="anchor" name="gffac609e575d3dc57392cc84b743e504"></a><!-- doxytag: member="queue.c::rt_queue_flush" ref="gffac609e575d3dc57392cc84b743e504" args="(RT_QUEUE *q)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_flush </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Flush a message queue.
<p>
This service discards all unread messages from a message 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>q</em> </td><td>The descriptor address of the affected queue.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of messages flushed is returned upon success. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</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="src_2skins_2native_2queue_8c-source.html#l00120">rt_queue_free()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g40d16a5ab14ea033889bb839967204e4"></a><!-- doxytag: member="queue.c::rt_queue_free" ref="g40d16a5ab14ea033889bb839967204e4" args="(RT_QUEUE *q, void *buf)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_free </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>buf</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Free a message queue buffer.
<p>
This service releases a message buffer returned by <a class="el" href="group__native__queue.html#g44759168a589ddbb2b60c1c1b183f448" title="Receive a message from a queue.">rt_queue_receive()</a> to the queue's internal pool.<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>q</em> </td><td>The descriptor address of the affected queue.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buf</em> </td><td>The address of the message buffer to free. Even zero-sized messages carrying no payload data must be freed, since they are assigned a valid memory space to store internal information.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 is returned upon success, or -EINVAL if <em>buf</em> is not a valid message buffer previously allocated by the <a class="el" href="group__native__queue.html#g8eaee8ca7d0c3af801c4df6f0adae421" title="Allocate a message queue buffer.">rt_queue_alloc()</a> service, or the caller did not get ownership of the message through a successful return from <a class="el" href="group__native__queue.html#g44759168a589ddbb2b60c1c1b183f448" title="Receive a message from a queue.">rt_queue_receive()</a>.</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.
<p>References <a class="el" href="ksrc_2nucleus_2heap_8c-source.html#l00622">xnheap_test_and_free()</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2queue_8c-source.html#l01142">rt_queue_flush()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g654017c0f87d8c23329aeefff93e6a70"></a><!-- doxytag: member="queue.c::rt_queue_inquire" ref="g654017c0f87d8c23329aeefff93e6a70" args="(RT_QUEUE *q, RT_QUEUE_INFO *info)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_inquire </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">RT_QUEUE_INFO * </td>
<td class="paramname"> <em>info</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Inquire about a message queue.
<p>
Return various information about the status of a given 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>q</em> </td><td>The descriptor address of the inquired queue.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>info</em> </td><td>The address of a structure the queue information will be written to.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 is returned and status information is written to the structure pointed at by <em>info</em> upon success. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</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.
</div>
</div><p>
<a class="anchor" name="g4083beec0186ce66c66ee0d3fc1b5eee"></a><!-- doxytag: member="queue.c::rt_queue_read" ref="g4083beec0186ce66c66ee0d3fc1b5eee" args="(RT_QUEUE *q, void *buf, size_t size, RTIME timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ssize_t rt_queue_read </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">RTIME </td>
<td class="paramname"> <em>timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Read a message from a queue.
<p>
This service retrieves the next message available from the given queue. Unless otherwise specified, the caller is blocked for a given amount of time if no message is immediately available on entry. This services differs from <a class="el" href="group__native__queue.html#g44759168a589ddbb2b60c1c1b183f448" title="Receive a message from a queue.">rt_queue_receive()</a> in that it copies back the payload data to a user-defined memory area, instead of returning a pointer to the message buffer holding such data.<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>q</em> </td><td>The descriptor address of the message queue to read from.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buf</em> </td><td>A pointer to a memory area which will be written upon success with the message contents. The internal message buffer conveying the data is automatically freed by this call.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The length in bytes of the memory area pointed to by <em>buf</em>. Messages larger than <em>size</em> are truncated appropriately.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The number of clock ticks to wait for a message to arrive (see note). Passing TM_INFINITE causes the caller to block indefinitely until some message is eventually available. Passing TM_NONBLOCK causes the service to return immediately without waiting if no message is available on entry.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes available from the received message is returned upon success, which might be greater than the actual number of bytes copied to the destination buffer if the message has been truncated. Zero is a possible value corresponding to a zero-sized message passed to <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a> or <a class="el" href="group__native__queue.html#g9ef8d1826bb13fe706a4566890972657" title="Write a message to a queue.">rt_queue_write()</a>. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-ETIMEDOUT is returned if <em>timeout</em> is different from TM_NONBLOCK and no message is available within the specified amount of time.</li></ul>
<p>
<ul>
<li>-EWOULDBLOCK is returned if <em>timeout</em> is equal to TM_NONBLOCK and no message is immediately available on entry.</li></ul>
<p>
<ul>
<li>-EINTR is returned if <a class="el" href="group__task.html#g770281eeca009c0a08a7c4a9fd849ac1" title="Unblock a real-time task.">rt_task_unblock()</a> has been called for the waiting task before any data was available.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service should block, but was called from a context which cannot sleep (e.g. interrupt, non-realtime context).</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine only if <em>timeout</em> is equal to TM_NONBLOCK.</li></ul>
<p>
<ul>
<li>Kernel-based task</li><li>User-space task (switches to primary mode)</li></ul>
<p>
Rescheduling: always unless the request is immediately satisfied or <em>timeout</em> specifies a non-blocking operation.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the native skin is bound to a periodic time base (see CONFIG_XENO_OPT_NATIVE_PERIOD), or nanoseconds otherwise. </dd></dl>
<p>References <a class="el" href="cancel_8c-source.html#l00279">pthread_setcanceltype()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g91dca49cc0fd0b30b8fe66eb6bc7ea8a"></a><!-- doxytag: member="queue.c::rt_queue_read_until" ref="g91dca49cc0fd0b30b8fe66eb6bc7ea8a" args="(RT_QUEUE *q, void *buf, size_t size, RTIME timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ssize_t rt_queue_read_until </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">RTIME </td>
<td class="paramname"> <em>timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Read a message from a queue (with absolute timeout date).
<p>
This service retrieves the next message available from the given queue. Unless otherwise specified, the caller is blocked for a given amount of time if no message is immediately available on entry. This services differs from <a class="el" href="group__native__queue.html#g44759168a589ddbb2b60c1c1b183f448" title="Receive a message from a queue.">rt_queue_receive()</a> in that it copies back the payload data to a user-defined memory area, instead of returning a pointer to the message buffer holding such data.<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>q</em> </td><td>The descriptor address of the message queue to read from.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buf</em> </td><td>A pointer to a memory area which will be written upon success with the message contents. The internal message buffer conveying the data is automatically freed by this call.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The length in bytes of the memory area pointed to by <em>buf</em>. Messages larger than <em>size</em> are truncated appropriately.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The absolute date specifying a time limit to wait for a message to arrive (see note). Passing TM_INFINITE causes the caller to block indefinitely until some message is eventually available. Passing TM_NONBLOCK causes the service to return immediately without waiting if no message is available on entry.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes available from the received message is returned upon success, which might be greater than the actual number of bytes copied to the destination buffer if the message has been truncated. Zero is a possible value corresponding to a zero-sized message passed to <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a> or <a class="el" href="group__native__queue.html#g9ef8d1826bb13fe706a4566890972657" title="Write a message to a queue.">rt_queue_write()</a>. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-ETIMEDOUT is returned if the absolute <em>timeout</em> date is reached before a message arrives.</li></ul>
<p>
<ul>
<li>-EWOULDBLOCK is returned if <em>timeout</em> is equal to TM_NONBLOCK and no message is immediately available on entry.</li></ul>
<p>
<ul>
<li>-EINTR is returned if <a class="el" href="group__task.html#g770281eeca009c0a08a7c4a9fd849ac1" title="Unblock a real-time task.">rt_task_unblock()</a> has been called for the waiting task before any data was available.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service should block, but was called from a context which cannot sleep (e.g. interrupt, non-realtime context).</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine only if <em>timeout</em> is equal to TM_NONBLOCK.</li></ul>
<p>
<ul>
<li>Kernel-based task</li><li>User-space task (switches to primary mode)</li></ul>
<p>
Rescheduling: always unless the request is immediately satisfied or <em>timeout</em> specifies a non-blocking operation.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the native skin is bound to a periodic time base (see CONFIG_XENO_OPT_NATIVE_PERIOD), or nanoseconds otherwise. </dd></dl>
<p>References <a class="el" href="cancel_8c-source.html#l00279">pthread_setcanceltype()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g44759168a589ddbb2b60c1c1b183f448"></a><!-- doxytag: member="queue.c::rt_queue_receive" ref="g44759168a589ddbb2b60c1c1b183f448" args="(RT_QUEUE *q, void **bufp, RTIME timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ssize_t rt_queue_receive </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void ** </td>
<td class="paramname"> <em>bufp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">RTIME </td>
<td class="paramname"> <em>timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Receive a message from a queue.
<p>
This service retrieves the next message available from the given queue. Unless otherwise specified, the caller is blocked for a given amount of time if no message is immediately available on entry.<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>q</em> </td><td>The descriptor address of the message queue to receive from.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>bufp</em> </td><td>A pointer to a memory location which will be written upon success with the address of the received message. Once consumed, the message space should be freed using <a class="el" href="group__native__queue.html#g40d16a5ab14ea033889bb839967204e4" title="Free a message queue buffer.">rt_queue_free()</a>.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The number of clock ticks to wait for a message to arrive (see note). Passing TM_INFINITE causes the caller to block indefinitely until some message is eventually available. Passing TM_NONBLOCK causes the service to return immediately without waiting if no message is available on entry.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes available from the received message is returned upon success. Zero is a possible value corresponding to a zero-sized message passed to <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a>. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-ETIMEDOUT is returned if <em>timeout</em> is different from TM_NONBLOCK and no message is available within the specified amount of time.</li></ul>
<p>
<ul>
<li>-EWOULDBLOCK is returned if <em>timeout</em> is equal to TM_NONBLOCK and no message is immediately available on entry.</li></ul>
<p>
<ul>
<li>-EINTR is returned if <a class="el" href="group__task.html#g770281eeca009c0a08a7c4a9fd849ac1" title="Unblock a real-time task.">rt_task_unblock()</a> has been called for the waiting task before any data was available.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service should block, but was called from a context which cannot sleep (e.g. interrupt, non-realtime context).</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine only if <em>timeout</em> is equal to TM_NONBLOCK.</li></ul>
<p>
<ul>
<li>Kernel-based task</li><li>User-space task (switches to primary mode)</li></ul>
<p>
Rescheduling: always unless the request is immediately satisfied or <em>timeout</em> specifies a non-blocking operation.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the native skin is bound to a periodic time base (see CONFIG_XENO_OPT_NATIVE_PERIOD), or nanoseconds otherwise. </dd></dl>
<p>References <a class="el" href="cancel_8c-source.html#l00279">pthread_setcanceltype()</a>.</p>
</div>
</div><p>
<a class="anchor" name="gde7b66ff83b602b6265cb1cb768c18db"></a><!-- doxytag: member="queue.c::rt_queue_receive_until" ref="gde7b66ff83b602b6265cb1cb768c18db" args="(RT_QUEUE *q, void **bufp, RTIME timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ssize_t rt_queue_receive_until </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void ** </td>
<td class="paramname"> <em>bufp</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">RTIME </td>
<td class="paramname"> <em>timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Receive a message from a queue (with absolute timeout date).
<p>
This service retrieves the next message available from the given queue. Unless otherwise specified, the caller is blocked for a given amount of time if no message is immediately available on entry.<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>q</em> </td><td>The descriptor address of the message queue to receive from.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>bufp</em> </td><td>A pointer to a memory location which will be written upon success with the address of the received message. Once consumed, the message space should be freed using <a class="el" href="group__native__queue.html#g40d16a5ab14ea033889bb839967204e4" title="Free a message queue buffer.">rt_queue_free()</a>.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The absolute date specifying a time limit to wait for a message to arrive (see note). Passing TM_INFINITE causes the caller to block indefinitely until some message is eventually available. Passing TM_NONBLOCK causes the service to return immediately without waiting if no message is available on entry.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The number of bytes available from the received message is returned upon success. Zero is a possible value corresponding to a zero-sized message passed to <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a>. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-ETIMEDOUT is returned if the absolute <em>timeout</em> date is reached before a message arrives.</li></ul>
<p>
<ul>
<li>-EWOULDBLOCK is returned if <em>timeout</em> is equal to TM_NONBLOCK and no message is immediately available on entry.</li></ul>
<p>
<ul>
<li>-EINTR is returned if <a class="el" href="group__task.html#g770281eeca009c0a08a7c4a9fd849ac1" title="Unblock a real-time task.">rt_task_unblock()</a> has been called for the waiting task before any data was available.</li></ul>
<p>
<ul>
<li>-EPERM is returned if this service should block, but was called from a context which cannot sleep (e.g. interrupt, non-realtime context).</li></ul>
<p>
Environments:<p>
This service can be called from:<p>
<ul>
<li>Kernel module initialization/cleanup code</li><li>Interrupt service routine only if <em>timeout</em> is equal to TM_NONBLOCK.</li></ul>
<p>
<ul>
<li>Kernel-based task</li><li>User-space task (switches to primary mode)</li></ul>
<p>
Rescheduling: always unless the request is immediately satisfied or <em>timeout</em> specifies a non-blocking operation.<p>
<dl class="note" compact><dt><b>Note:</b></dt><dd>The <em>timeout</em> value will be interpreted as jiffies if the native skin is bound to a periodic time base (see CONFIG_XENO_OPT_NATIVE_PERIOD), or nanoseconds otherwise. </dd></dl>
<p>References <a class="el" href="cancel_8c-source.html#l00279">pthread_setcanceltype()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g8b1dcb15753bdfce02f25f166e18948d"></a><!-- doxytag: member="queue.c::rt_queue_send" ref="g8b1dcb15753bdfce02f25f166e18948d" args="(RT_QUEUE *q, void *mbuf, size_t size, int mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_send </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void * </td>
<td class="paramname"> <em>mbuf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>mode</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Send a message to a queue.
<p>
This service sends a complete message to a given queue. The message must have been allocated by a previous call to <a class="el" href="group__native__queue.html#g8eaee8ca7d0c3af801c4df6f0adae421" title="Allocate a message queue buffer.">rt_queue_alloc()</a>.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>q</em> </td><td>The descriptor address of the message queue to send to.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>mbuf</em> </td><td>The address of the message buffer to be sent. The message buffer must have been allocated using the <a class="el" href="group__native__queue.html#g8eaee8ca7d0c3af801c4df6f0adae421" title="Allocate a message queue buffer.">rt_queue_alloc()</a> service. Once passed to <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a>, the memory pointed to by <em>mbuf</em> is no more under the control of the sender and thus should not be referenced by it anymore; deallocation of this memory must be handled on the receiving side.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The size in bytes of the message. Zero is a valid value, in which case an empty message will be sent.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>mode</em> </td><td>A set of flags affecting the operation:</td></tr>
</table>
</dl>
<ul>
<li>Q_URGENT causes the message to be prepended to the message queue, ensuring a LIFO ordering.</li></ul>
<p>
<ul>
<li>Q_NORMAL causes the message to be appended to the message queue, ensuring a FIFO ordering.</li></ul>
<p>
<ul>
<li>Q_BROADCAST causes the message to be sent to all tasks currently waiting for messages. The message is not copied; a reference count is maintained instead so that the message will remain valid until the last receiver releases its own reference using <a class="el" href="group__native__queue.html#g40d16a5ab14ea033889bb839967204e4" title="Free a message queue buffer.">rt_queue_free()</a>, after which the message space will be returned to the queue's internal pool.</li></ul>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Upon success, this service returns the number of receivers which got awaken as a result of the operation. If zero is returned, no task was waiting on the receiving side of the queue, and the message has been enqueued. Upon error, one of the following error codes is returned:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor, or <em>mbuf</em> is not a valid message buffer obtained from a previous call to <a class="el" href="group__native__queue.html#g8eaee8ca7d0c3af801c4df6f0adae421" title="Allocate a message queue buffer.">rt_queue_alloc()</a>.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-ENOMEM is returned if queuing the message would exceed the limit defined for the queue at creation.</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: possible.
<p>References <a class="el" href="cancel_8c-source.html#l00279">pthread_setcanceltype()</a>, <a class="el" href="pod_8h-source.html#l00251">xnpod_schedule()</a>, and <a class="el" href="synch_8c-source.html#l00237">xnsynch_wakeup_one_sleeper()</a>.</p>
<p>Referenced by <a class="el" href="ksrc_2skins_2native_2queue_8c-source.html#l00727">rt_queue_write()</a>.</p>
</div>
</div><p>
<a class="anchor" name="g1f190858ca18d906db339e086bfa8ced"></a><!-- doxytag: member="queue.c::rt_queue_unbind" ref="g1f190858ca18d906db339e086bfa8ced" args="(RT_QUEUE *q)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_unbind </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Unbind from a shared message queue.
<p>
This user-space only service unbinds the calling task from the message queue object previously retrieved by a call to <a class="el" href="group__native__queue.html#g162bb372c5c3616666e8e1fbdcc79343" title="Bind to a shared message queue.">rt_queue_bind()</a>.<p>
Unbinding from a message queue when it is no more needed is especially important in order to properly release the mapping resources used to attach the shared queue memory to the caller's address space.<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>q</em> </td><td>The address of a queue descriptor to unbind from.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 is returned upon success. Otherwise:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is invalid or not bound.</li></ul>
<p>
This service can be called from:<p>
<ul>
<li>User-space task.</li></ul>
<p>
Rescheduling: never. <dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="msg__queue_8c-example.html#a3">msg_queue.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g9ef8d1826bb13fe706a4566890972657"></a><!-- doxytag: member="queue.c::rt_queue_write" ref="g9ef8d1826bb13fe706a4566890972657" args="(RT_QUEUE *q, const void *buf, size_t size, int mode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int rt_queue_write </td>
<td>(</td>
<td class="paramtype">RT_QUEUE * </td>
<td class="paramname"> <em>q</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const void * </td>
<td class="paramname"> <em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int </td>
<td class="paramname"> <em>mode</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Write a message to a queue.
<p>
This service writes a complete message to a given queue. This service differs from <a class="el" href="group__native__queue.html#g8b1dcb15753bdfce02f25f166e18948d" title="Send a message to a queue.">rt_queue_send()</a> in that it accepts a pointer to the raw data to be sent, instead of a canned message buffer.<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>q</em> </td><td>The descriptor address of the message queue to write to.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buf</em> </td><td>The address of the message data to be written to the queue. A message buffer will be allocated internally to convey the data.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>size</em> </td><td>The size in bytes of the message data. Zero is a valid value, in which case an empty message will be sent.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>mode</em> </td><td>A set of flags affecting the operation:</td></tr>
</table>
</dl>
<ul>
<li>Q_URGENT causes the message to be prepended to the message queue, ensuring a LIFO ordering.</li></ul>
<p>
<ul>
<li>Q_NORMAL causes the message to be appended to the message queue, ensuring a FIFO ordering.</li></ul>
<p>
<ul>
<li>Q_BROADCAST causes the message to be sent to all tasks currently waiting for messages. The message is not copied; a reference count is maintained instead so that the message will remain valid until all receivers get a copy of the message, after which the message space will be returned to the queue's internal pool.</li></ul>
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Upon success, this service returns the number of receivers which got awaken as a result of the operation. If zero is returned, no task was waiting on the receiving side of the queue, and the message has been enqueued. Upon error, one of the following error codes is returned:</dd></dl>
<ul>
<li>-EINVAL is returned if <em>q</em> is not a message queue descriptor.</li></ul>
<p>
<ul>
<li>-EIDRM is returned if <em>q</em> is a deleted queue descriptor.</li></ul>
<p>
<ul>
<li>-ENOMEM is returned if queuing the message would exceed the limit defined for the queue at creation, or if no memory can be obtained to convey the message data internally.</li></ul>
<p>
<ul>
<li>-ESRCH is returned if a <em>q</em> represents a stale userland handle</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: possible.
<p>References <a class="el" href="cancel_8c-source.html#l00279">pthread_setcanceltype()</a>, <a class="el" href="src_2skins_2native_2queue_8c-source.html#l00111">rt_queue_alloc()</a>, and <a class="el" href="src_2skins_2native_2queue_8c-source.html#l00125">rt_queue_send()</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>
|