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
|
<!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 queues 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 queues services.<br>
<small>
[<a class="el" href="group__posix.html">POSIX skin.</a>]</small>
</h1>
<p>
<div class="dynheader">
Collaboration diagram for Message queues services.:</div>
<div class="dynsection">
<center><table><tr><td><img src="group__posix__mq.png" border="0" alt="" usemap="#group____posix____mq_map">
<map name="group____posix____mq_map">
<area shape="rect" href="group__posix.html" title="Xenomai POSIX skin is an implementation of a small subset of the Single Unix specification..." alt="" coords="7,5,100,32"></map></td></tr></table></center>
</div>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Message queues services.
<p>
A message queue allow exchanging data between real-time threads. For a POSIX message queue, maximum message length and maximum number of messages are fixed when it is created with <a class="el" href="group__posix__mq.html#g6e6c4881ac0fd3ad18d733b96d088b8b" title="Open a message queue.">mq_open()</a>.
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">mqd_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group__posix__mq.html#g6e6c4881ac0fd3ad18d733b96d088b8b">mq_open</a> (const char *name, int oflags,...)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Open a message queue. <a href="#g6e6c4881ac0fd3ad18d733b96d088b8b"></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__posix__mq.html#g14a1dc0204a7f84bb4e8a1813a70af49">mq_close</a> (mqd_t fd)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Close a message queue. <a href="#g14a1dc0204a7f84bb4e8a1813a70af49"></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__posix__mq.html#gccd8c5ee36e60d990963e1d544ef4140">mq_unlink</a> (const char *name)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Unlink a message queue. <a href="#gccd8c5ee36e60d990963e1d544ef4140"></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__posix__mq.html#ge3d8e022fcc1114c0cd4b30ccd1f15e4">mq_send</a> (mqd_t fd, const char *buffer, size_t len, unsigned prio)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Send a message to a message queue. <a href="#ge3d8e022fcc1114c0cd4b30ccd1f15e4"></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__posix__mq.html#gcf2baf29d0ad8c7c49bc42793c36f0a2">mq_timedsend</a> (mqd_t fd, const char *buffer, size_t len, unsigned prio, const struct timespec *abs_timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Attempt, during a bounded time, to send a message to a message queue. <a href="#gcf2baf29d0ad8c7c49bc42793c36f0a2"></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__posix__mq.html#g6370a6bb8f2b87e52ec4fcf340939128">mq_receive</a> (mqd_t fd, char *buffer, size_t len, unsigned *priop)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Receive a message from a message queue. <a href="#g6370a6bb8f2b87e52ec4fcf340939128"></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__posix__mq.html#g5e82a3bba3003f84bccb615adcba1f57">mq_timedreceive</a> (mqd_t fd, char *__restrict__ buffer, size_t len, unsigned *__restrict__ priop, const struct timespec *__restrict__ abs_timeout)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Attempt, during a bounded time, to receive a message from a message queue. <a href="#g5e82a3bba3003f84bccb615adcba1f57"></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__posix__mq.html#gccb588f0005137d7b4db3cff0fb7f7fe">mq_getattr</a> (mqd_t fd, struct mq_attr *attr)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the attributes object of a message queue. <a href="#gccb588f0005137d7b4db3cff0fb7f7fe"></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__posix__mq.html#gb7670280d7cf1753b1448fb3ad61befc">mq_setattr</a> (mqd_t fd, const struct mq_attr *__restrict__ attr, struct mq_attr *__restrict__ oattr)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set flags of a message queue. <a href="#gb7670280d7cf1753b1448fb3ad61befc"></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__posix__mq.html#g346fbeb512b59ecf90be445718724936">mq_notify</a> (mqd_t fd, const struct sigevent *evp)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Register the current thread to be notified of message arrival at an empty message queue. <a href="#g346fbeb512b59ecf90be445718724936"></a><br></td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="g14a1dc0204a7f84bb4e8a1813a70af49"></a><!-- doxytag: member="mq.c::mq_close" ref="g14a1dc0204a7f84bb4e8a1813a70af49" args="(mqd_t fd)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_close </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Close a message queue.
<p>
This service closes the message queue descriptor <em>fd</em>. The message queue is destroyed only when all open descriptors are closed, and when unlinked with a call to the <a class="el" href="group__posix__mq.html#gccd8c5ee36e60d990963e1d544ef4140" title="Unlink a message queue.">mq_unlink()</a> service.<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>fd</em> </td><td>message queue descriptor.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>on success; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-1</em> </td><td>with <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is an invalid message queue descriptor;</li><li>EPERM, the caller context is invalid.</li></ul>
</td></tr>
</table>
</dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>kernel module initialization or cleanup routine;</li><li>kernel-space cancellation cleanup routine;</li><li>user-space thread (Xenomai threads switch to secondary mode);</li><li>user-space cancellation cleanup routine.</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_close.html">Specification.</a> </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="rtcan__rtt_8c-example.html#a8">rtcan_rtt.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="gccb588f0005137d7b4db3cff0fb7f7fe"></a><!-- doxytag: member="mq.c::mq_getattr" ref="gccb588f0005137d7b4db3cff0fb7f7fe" args="(mqd_t fd, struct mq_attr *attr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_getattr </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct mq_attr * </td>
<td class="paramname"> <em>attr</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Get the attributes object of a message queue.
<p>
This service stores, at the address <em>attr</em>, the attributes of the messages queue descriptor <em>fd</em>.<p>
The following attributes are set:<ul>
<li><em>mq_flags</em>, flags of the message queue descriptor <em>fd</em>;</li><li><em>mq_maxmsg</em>, maximum number of messages in the message queue;</li><li><em>mq_msgsize</em>, maximum message size;</li><li><em>mq_curmsgs</em>, number of messages currently in the queue.</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>fd</em> </td><td>message queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>attr</em> </td><td>address where the message queue attributes will be stored on success.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>on success; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-1</em> </td><td>with <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is not a valid descriptor.</li></ul>
</td></tr>
</table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_getattr.html">Specification.</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="g346fbeb512b59ecf90be445718724936"></a><!-- doxytag: member="mq.c::mq_notify" ref="g346fbeb512b59ecf90be445718724936" args="(mqd_t fd, const struct sigevent *evp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_notify </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct sigevent * </td>
<td class="paramname"> <em>evp</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Register the current thread to be notified of message arrival at an empty message queue.
<p>
If <em>evp</em> is not <em>NULL</em> and is the address of a <b>sigevent</b> structure with the <em>sigev_notify</em> member set to SIGEV_SIGNAL, the current thread will be notified by a signal when a message is sent to the message queue <em>fd</em>, the queue is empty, and no thread is blocked in call to <a class="el" href="group__posix__mq.html#g6370a6bb8f2b87e52ec4fcf340939128" title="Receive a message from a message queue.">mq_receive()</a> or <a class="el" href="group__posix__mq.html#g5e82a3bba3003f84bccb615adcba1f57" title="Attempt, during a bounded time, to receive a message from a message queue.">mq_timedreceive()</a>. After the notification, the thread is unregistered.<p>
If <em>evp</em> is <em>NULL</em> or the <em>sigev_notify</em> member is SIGEV_NONE, the current thread is unregistered.<p>
Only one thread may be registered at a time.<p>
If the current thread is not a Xenomai POSIX skin thread (created with <a class="el" href="group__posix__thread.html#ge6e819ed048e4c4a4ee96fa6f426852c" title="Create a thread.">pthread_create()</a>), this service fails.<p>
Note that signals sent to user-space Xenomai POSIX skin threads will cause them to switch to secondary mode.<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>fd</em> </td><td>message queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>evp</em> </td><td>pointer to an event notification structure.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>on success; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-1</em> </td><td>with <em>errno</em> set if:<ul>
<li>EINVAL, <em>evp</em> is invalid;</li><li>EPERM, the caller context is invalid;</li><li>EBADF, <em>fd</em> is not a valid message queue descriptor;</li><li>EBUSY, another thread is already registered.</li></ul>
</td></tr>
</table>
</dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>Xenomai kernel-space POSIX skin thread,</li><li>Xenomai user-space POSIX skin thread (switches to primary mode).</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_notify.html">Specification.</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="g6e6c4881ac0fd3ad18d733b96d088b8b"></a><!-- doxytag: member="mq.c::mq_open" ref="g6e6c4881ac0fd3ad18d733b96d088b8b" args="(const char *name, int oflags,...)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">mqd_t mq_open </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">int </td>
<td class="paramname"> <em>oflags</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"> </td>
<td class="paramname"> <em>...</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Open a message queue.
<p>
This service establishes a connection between the message queue named <em>name</em> and the calling context (kernel-space as a whole, or user-space process).<p>
One of the following values should be set in <em>oflags:</em> <ul>
<li>O_RDONLY, meaning that the returned queue descriptor may only be used for receiving messages;</li><li>O_WRONLY, meaning that the returned queue descriptor may only be used for sending messages;</li><li>O_RDWR, meaning that the returned queue descriptor may be used for both sending and receiving messages.</li></ul>
<p>
If no message queue named <em>name</em> exists, and <em>oflags</em> has the <em>O_CREAT</em> bit set, the message queue is created by this function, taking two more arguments:<ul>
<li>a <em>mode</em> argument, of type <b>mode_t</b>, currently ignored;</li><li>an <em>attr</em> argument, pointer to an <b>mq_attr</b> structure, specifying the attributes of the new message queue.</li></ul>
<p>
If <em>oflags</em> has the two bits <em>O_CREAT</em> and <em>O_EXCL</em> set and the message queue alread exists, this service fails.<p>
If the O_NONBLOCK bit is set in <em>oflags</em>, the <a class="el" href="group__posix__mq.html#ge3d8e022fcc1114c0cd4b30ccd1f15e4" title="Send a message to a message queue.">mq_send()</a>, <a class="el" href="group__posix__mq.html#g6370a6bb8f2b87e52ec4fcf340939128" title="Receive a message from a message queue.">mq_receive()</a>, <a class="el" href="group__posix__mq.html#gcf2baf29d0ad8c7c49bc42793c36f0a2" title="Attempt, during a bounded time, to send a message to a message queue.">mq_timedsend()</a> and <a class="el" href="group__posix__mq.html#g5e82a3bba3003f84bccb615adcba1f57" title="Attempt, during a bounded time, to receive a message from a message queue.">mq_timedreceive()</a> services return <em>-1</em> with <em>errno</em> set to EAGAIN instead of blocking their caller.<p>
The following arguments of the <b>mq_attr</b> structure at the address <em>attr</em> are used when creating a message queue:<ul>
<li><em>mq_maxmsg</em> is the maximum number of messages in the queue (128 by default);</li><li><em>mq_msgsize</em> is the maximum size of each message (128 by default).</li></ul>
<p>
<em>name</em> may be any arbitrary string, in which slashes have no particular meaning. However, for portability, using a name which starts with a slash and contains no other slash is recommended.<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>name of the message queue to open;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>oflags</em> </td><td>flags.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>a message queue descriptor on success; <p>
-1 with <em>errno</em> set if:<ul>
<li>ENAMETOOLONG, the length of the <em>name</em> argument exceeds 64 characters;</li><li>EEXIST, the bits <em>O_CREAT</em> and <em>O_EXCL</em> were set in <em>oflags</em> and the message queue already exists;</li><li>ENOENT, the bit <em>O_CREAT</em> is not set in <em>oflags</em> and the message queue does not exist;</li><li>ENOSPC, allocation of system memory failed, or insufficient memory exists in the system heap to create the queue, try increasing CONFIG_XENO_OPT_SYS_HEAPSZ;</li><li>EPERM, attempting to create a message queue from an invalid context;</li><li>EINVAL, the <em>attr</em> argument is invalid;</li><li>EMFILE, too many descriptors are currently open.</li></ul>
</dd></dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd>When creating a message queue, only the following contexts are valid:<ul>
<li>kernel module initialization or cleanup routine;</li><li>user-space thread (Xenomai threads switch to secondary mode).</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_open.html">Specification.</a> </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="rtcan__rtt_8c-example.html#a17">rtcan_rtt.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="g6370a6bb8f2b87e52ec4fcf340939128"></a><!-- doxytag: member="mq.c::mq_receive" ref="g6370a6bb8f2b87e52ec4fcf340939128" args="(mqd_t fd, char *buffer, size_t len, unsigned *priop)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ssize_t mq_receive </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char * </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned * </td>
<td class="paramname"> <em>priop</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 message queue.
<p>
If the message queue <em>fd</em> is not empty and if <em>len</em> is greater than the <em>mq_msgsize</em> of the message queue, this service copies, at the address <em>buffer</em>, the queued message with the highest priority.<p>
If the queue is empty and the flag <em>O_NONBLOCK</em> is not set for the descriptor <em>fd</em>, the calling thread is suspended until some message is sent to the queue. If the queue is empty and the flag <em>O_NONBLOCK</em> is set for the descriptor <em>fd</em>, this service returns immediately a value of -1 with <em>errno</em> set to EAGAIN.<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>fd</em> </td><td>the queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buffer</em> </td><td>the address where the received message will be stored on success;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em> </td><td><em>buffer</em> length;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>priop</em> </td><td>address where the priority of the received message will be stored on success.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the message length, and copy a message at the address <em>buffer</em> on success; <p>
-1 with no message unqueued and <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is not a valid descriptor open for reading;</li><li>EMSGSIZE, the length <em>len</em> is lesser than the message queue <em>mq_msgsize</em> attribute;</li><li>EAGAIN, the queue is empty, and the flag <em>O_NONBLOCK</em> is set for the descriptor <em>fd</em>;</li><li>EPERM, the caller context is invalid;</li><li>EINTR, the service was interrupted by a signal.</li></ul>
</dd></dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>Xenomai kernel-space thread,</li><li>Xenomai user-space thread (switches to primary mode).</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_receive.html">Specification.</a> </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="rtcan__rtt_8c-example.html#a22">rtcan_rtt.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="ge3d8e022fcc1114c0cd4b30ccd1f15e4"></a><!-- doxytag: member="mq.c::mq_send" ref="ge3d8e022fcc1114c0cd4b30ccd1f15e4" args="(mqd_t fd, const char *buffer, size_t len, unsigned prio)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_send </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned </td>
<td class="paramname"> <em>prio</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 message queue.
<p>
If the message queue <em>fd</em> is not full, this service sends the message of length <em>len</em> pointed to by the argument <em>buffer</em>, with priority <em>prio</em>. A message with greater priority is inserted in the queue before a message with lower priority.<p>
If the message queue is full and the flag <em>O_NONBLOCK</em> is not set, the calling thread is suspended until the queue is not full. If the message queue is full and the flag <em>O_NONBLOCK</em> is set, the message is not sent and the service returns immediately a value of -1 with <em>errno</em> set to EAGAIN.<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>fd</em> </td><td>message queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buffer</em> </td><td>pointer to the message to be sent;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>length of the message;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>prio</em> </td><td>priority of the message.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 and send a message on success; <p>
-1 with no message sent and <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is not a valid message queue descriptor open for writing;</li><li>EMSGSIZE, the message length <em>len</em> exceeds the <em>mq_msgsize</em> attribute of the message queue;</li><li>EAGAIN, the flag O_NONBLOCK is set for the descriptor <em>fd</em> and the message queue is full;</li><li>EPERM, the caller context is invalid;</li><li>EINTR, the service was interrupted by a signal.</li></ul>
</dd></dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>Xenomai kernel-space thread,</li><li>Xenomai user-space thread (switches to primary mode).</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_send.html">Specification.</a> </dd></dl>
<dl compact><dt><b>Examples: </b></dt><dd>
<a class="el" href="rtcan__rtt_8c-example.html#a7">rtcan_rtt.c</a>.</dl>
</div>
</div><p>
<a class="anchor" name="gb7670280d7cf1753b1448fb3ad61befc"></a><!-- doxytag: member="mq.c::mq_setattr" ref="gb7670280d7cf1753b1448fb3ad61befc" args="(mqd_t fd, const struct mq_attr *__restrict__ attr, struct mq_attr *__restrict__ oattr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_setattr </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct mq_attr *__restrict__ </td>
<td class="paramname"> <em>attr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">struct mq_attr *__restrict__ </td>
<td class="paramname"> <em>oattr</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Set flags of a message queue.
<p>
This service sets the flags of the <em>fd</em> descriptor to the value of the member <em>mq_flags</em> of the <b>mq_attr</b> structure pointed to by <em>attr</em>.<p>
The previous value of the message queue attributes are stored at the address <em>oattr</em> if it is not <em>NULL</em>.<p>
Only setting or clearing the O_NONBLOCK flag has an effect.<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>fd</em> </td><td>message queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>attr</em> </td><td>pointer to new attributes (only <em>mq_flags</em> is used);</td></tr>
<tr><td valign="top"></td><td valign="top"><em>oattr</em> </td><td>if not <em>NULL</em>, address where previous message queue attributes will be stored on success.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>on success; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-1</em> </td><td>with <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is not a valid message queue descriptor.</li></ul>
</td></tr>
</table>
</dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_setattr.html">Specification.</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="g5e82a3bba3003f84bccb615adcba1f57"></a><!-- doxytag: member="mq.c::mq_timedreceive" ref="g5e82a3bba3003f84bccb615adcba1f57" args="(mqd_t fd, char *__restrict__ buffer, size_t len, unsigned *__restrict__ priop, const struct timespec *__restrict__ abs_timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ssize_t mq_timedreceive </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *__restrict__ </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned *__restrict__ </td>
<td class="paramname"> <em>priop</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct timespec *__restrict__ </td>
<td class="paramname"> <em>abs_timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Attempt, during a bounded time, to receive a message from a message queue.
<p>
This service is equivalent to <a class="el" href="group__posix__mq.html#g6370a6bb8f2b87e52ec4fcf340939128" title="Receive a message from a message queue.">mq_receive()</a>, except that if the flag <em>O_NONBLOCK</em> is not set for the descriptor <em>fd</em> and the message queue is empty, the calling thread is only suspended until the timeout <em>abs_timeout</em> expires.<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>fd</em> </td><td>the queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buffer</em> </td><td>the address where the received message will be stored on success;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em> </td><td><em>buffer</em> length;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>priop</em> </td><td>address where the priority of the received message will be stored on success.</td></tr>
<tr><td valign="top"></td><td valign="top"><em>abs_timeout</em> </td><td>the timeout, expressed as an absolute value of the CLOCK_REALTIME clock.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the message length, and copy a message at the address <em>buffer</em> on success; <p>
-1 with no message unqueued and <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is not a valid descriptor open for reading;</li><li>EMSGSIZE, the length <em>len</em> is lesser than the message queue <em>mq_msgsize</em> attribute;</li><li>EAGAIN, the queue is empty, and the flag <em>O_NONBLOCK</em> is set for the descriptor <em>fd</em>;</li><li>EPERM, the caller context is invalid;</li><li>EINTR, the service was interrupted by a signal;</li><li>ETIMEDOUT, the specified timeout expired.</li></ul>
</dd></dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>Xenomai kernel-space thread,</li><li>Xenomai user-space thread (switches to primary mode).</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_timedreceive.html">Specification.</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="gcf2baf29d0ad8c7c49bc42793c36f0a2"></a><!-- doxytag: member="mq.c::mq_timedsend" ref="gcf2baf29d0ad8c7c49bc42793c36f0a2" args="(mqd_t fd, const char *buffer, size_t len, unsigned prio, const struct timespec *abs_timeout)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_timedsend </td>
<td>(</td>
<td class="paramtype">mqd_t </td>
<td class="paramname"> <em>fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t </td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">unsigned </td>
<td class="paramname"> <em>prio</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const struct timespec * </td>
<td class="paramname"> <em>abs_timeout</em></td><td> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Attempt, during a bounded time, to send a message to a message queue.
<p>
This service is equivalent to <a class="el" href="group__posix__mq.html#ge3d8e022fcc1114c0cd4b30ccd1f15e4" title="Send a message to a message queue.">mq_send()</a>, except that if the message queue is full and the flag <em>O_NONBLOCK</em> is not set for the descriptor <em>fd</em>, the calling thread is only suspended until the timeout specified by <em>abs_timeout</em> expires.<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>fd</em> </td><td>message queue descriptor;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>buffer</em> </td><td>pointer to the message to be sent;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em> </td><td>length of the message;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>prio</em> </td><td>priority of the message;</td></tr>
<tr><td valign="top"></td><td valign="top"><em>abs_timeout</em> </td><td>the timeout, expressed as an absolute value of the CLOCK_REALTIME clock.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>0 and send a message on success; <p>
-1 with no message sent and <em>errno</em> set if:<ul>
<li>EBADF, <em>fd</em> is not a valid message queue descriptor open for writing;</li><li>EMSGSIZE, the message length exceeds the <em>mq_msgsize</em> attribute of the message queue;</li><li>EAGAIN, the flag O_NONBLOCK is set for the descriptor <em>fd</em> and the message queue is full;</li><li>EPERM, the caller context is invalid;</li><li>ETIMEDOUT, the specified timeout expired;</li><li>EINTR, the service was interrupted by a signal.</li></ul>
</dd></dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>Xenomai kernel-space thread,</li><li>Xenomai user-space thread (switches to primary mode).</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_timedsend.html">Specification.</a> </dd></dl>
</div>
</div><p>
<a class="anchor" name="gccd8c5ee36e60d990963e1d544ef4140"></a><!-- doxytag: member="mq.c::mq_unlink" ref="gccd8c5ee36e60d990963e1d544ef4140" args="(const char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int mq_unlink </td>
<td>(</td>
<td class="paramtype">const char * </td>
<td class="paramname"> <em>name</em> </td>
<td> ) </td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Unlink a message queue.
<p>
This service unlinks the message queue named <em>name</em>. The message queue is not destroyed until all queue descriptors obtained with the <a class="el" href="group__posix__mq.html#g6e6c4881ac0fd3ad18d733b96d088b8b" title="Open a message queue.">mq_open()</a> service are closed with the <a class="el" href="group__posix__mq.html#g14a1dc0204a7f84bb4e8a1813a70af49" title="Close a message queue.">mq_close()</a> service. However, after a call to this service, the unlinked queue may no longer be reached with the <a class="el" href="group__posix__mq.html#g6e6c4881ac0fd3ad18d733b96d088b8b" title="Open a message queue.">mq_open()</a> service.<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>name of the message queue to be unlinked.</td></tr>
</table>
</dl>
<dl compact><dt><b>Return values:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>0</em> </td><td>on success; </td></tr>
<tr><td valign="top"></td><td valign="top"><em>-1</em> </td><td>with <em>errno</em> set if:<ul>
<li>EPERM, the caller context is invalid;</li><li>ENAMETOOLONG, the length of the <em>name</em> argument exceeds 64 characters;</li><li>ENOENT, the message queue does not exist.</li></ul>
</td></tr>
</table>
</dl>
<dl class="user" compact><dt><b>Valid contexts:</b></dt><dd><ul>
<li>kernel module initialization or cleanup routine;</li><li>kernel-space cancellation cleanup routine;</li><li>user-space thread (Xenomai threads switch to secondary mode);</li><li>user-space cancellation cleanup routine.</li></ul>
</dd></dl>
<dl class="see" compact><dt><b>See also:</b></dt><dd><a href="http://www.opengroup.org/onlinepubs/000095399/functions/mq_unlink.html">Specification.</a> </dd></dl>
</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Aug 2 12:48:40 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>
|